That's just to demonstrate how you can complement the renderers you use and provide some extra metadata or props to them. Lastly, I'm gonna show you how you can use a simple renderer and this is an inline renderer. And this is probably something you might wanna do if you're doing testing or that was a super simple renderer, something you're not gonna share. You can just use an inline renderer. So you don't need to specify it externally. You can say something like, my inline renderer, p.value. So this is the same as above really, but you've got your in the browser, you see my inline renderer and the value. So you can finally specify something inline, you don't have to externalize it either into a separate file or into a separate const like we've done here. If it's super simple, or if you're just doing debugging or playing around, you can inline it as I've done there.
Okay, so what's next? So let's say that you've got a scenario where you want to have different renderers based on the value of the column. So you might want to say, renderer X if the data is one and renderer Y if the data is two, you can dynamically choose what you gonna show based on cell renderer selectors. Let me show you that. So you can have it static and that's probably the most common use case where you'd specify it like this, but you can have a dynamic with cell renderer selector. And that's a function that returns an object. And again, just to remind you, this is where this is the use case if you want different renderers in a cell and you want to dynamically switch between them to based on the row data or some other external factor. In our case, we're gonna do it based on row data. So, if the value is equal to 2000, we're gonna return and specify components, my renderer. We're gonna use this on a different field actually. If p.value equals 2004, we're gonna return, I'll describe what I've done here in a second. In this case, we're gonna have a inline components. I'm just gonna move this to another field. I want this to be on the year field. I'm going quite quickly, but I will describe what I've just done here. I've moved this, I've added a property called cell render selector, and that's fired per row data for this column, for every row in country year column. This will be fired. It'll pass down P, which has the API, grid API, the row data, and specifically the cell value for that cell. And what we're doing here is we're saying if the value, or if the year value is 2000, we'll return my cell, my render, the one we specified above with the button. And if the value is 2004, we're gonna create, return a simple inline component, and if the value is neither 2000 or 2004, we'll just up with the raw value. So let's save that and see what happens. So, here you can see for this value, for this row, the year value is 2008, we haven't specified what to do with 2008, so the grid will simply output the raw data. If the value is 2004, we're gonna return this inline component here, my inline components and add the value, and finally, if the value is 2000, we're gonna use my render with the button, as we said before. So, if you want some rows to have a special functionality or render, you can dynamically use, do so, with my cell-renderer selector. Whatever renderer you do, you use, you can still compliment it with cell-renderer params, as I've done here. So, for example, in, am I muted? Gosh, I'll take a look. I don't think I'm muted. Can anyone else hear me? Not to me, it's not, great. Woo, I'm glad to hear it. So, I'm sorry for Joe, it must be something on your end, I'm afraid. So, just to repeat, whatever we return, if it's a custom renderer, we can compliment it with cell-renderer params, and whatever we do in cell-renderer params will be made available in props. If you don't specify a component and a renderer to use, the grid will simply output the raw value of the adjacent data. I hope that makes sense. So, yeah, sorry, Joe, I'm not sure I can help you. If other people can hear, it must be something on your end, I'm afraid, but I don't think I can help you, Joe, apologies. Well, you can't hear me, I suppose. So, just to recap, we described how you can specify a cell-renderer. All you need to do is cell-renderer and then your renderer, so in this case, MyRenderer like that. You can also have inline renderers, hello, like that. And finally, you can have dynamic cell-renderers and you can choose different renderers based on the column data. Hopefully, that makes sense to everyone. That was pretty quick. I'll just take another sip of water. Just to recap, we remind you that the renderers I've done here are pretty simple. They simple, they've got simple buttons and simple data, but you could have anything. You could have a graph or a dynamic slider or spinning wheels. Anything that React can render in our components, functional or class-based components, you can render within the grid. The size of the components would obviously change the size of the row. So if you had those components with athlete button, and if you had those 30 pixels high, the whole row would be 36 pixels high to show that, but this point is anything that you, any React components you want to render in the grid, if it's a valid React component, it can render in the grid. How does the cell render if the line's too long? Okay, so I've kind of answered that. If you had a component, say, that was outputting a multi-line component with images and so on, it would fill up that height. So for example, if you had something that was outputting an image that's a 100 pixels high with a paragraph next to it, then the entire row, so this column, would be that high, 100 pixels high, with text next to it. So the whole row would be 100 pixels wide. The row height is determined by the highest, the biggest cell in that row. So if all the other rows, cells are 20 pixels high and the dynamic renderer has 100 pixels or higher, it'll be a 100 pixels higher, it's fairly dynamic. Yes, it is Bruno, it's dynamic. Yes, you can override that. You can say that you absolutely want your row heights to be 50 pixels and everything else to be clipped, for example, but by default, it will be dynamic. Have another simple water here.
Okay, so we'll move on to the next section. And it's going further with custom renders. And so, no it's not, it's called commit filters. So we're gonna touch on this section, on Filters. In the first section or two, I showed you how to enable filters, and out of the box with Enterprise Edition, you get set filter as a default, which is something we'd see here probably. So you see this is a set filter, which we'll describe later on. Let's remove the Enterprise functionality, and refresh. Don't worry about this error message. And we've gone back to a simple filter. So this just to discuss, for initially, for now. We provide out of the box three filters out of the box in the Community Edition. Again, the Community Edition is free for you to use, and commercially, you don't need a license, and out of the box, we provide a text filter, a number filter and a date filter. So let's go through those one by one. I'm gonna remove the renderer code, just for simplicity. Remember the code is on. If you wanna recap what I've done, just go look at the Github repo for the particular section you're interested in. It'll be there. I'm just gonna remove this code so we can see just what I'm trying to describe. Let this net can go. And there we go. So we're back to a simple Community Edition. There's no Enterprise Code here now. The first thing we're gonna look at is the text filter.
Comments