I have a paged RadGrid databound to a view. I catched the event ItemDataBound, and I translate fields in this method.
My filter works well, but with the non-translated label. How can I do to use the translation in my filter? I want to filter after databinding. Do I need to filter client side or can I do it server-side ?
Thanks in advance
7 Answers, 1 is accepted
In order to filter on the server you need to correctly construct the filter expressions of the grid as shown in this help topic:
http://www.telerik.com/help/aspnet-ajax/grid-operate-with-filter-expression-manually.html
Marin
the Telerik team
I think that my problem is not to construct a filter correctly, but is to apply a filter after databinding. Changing the filter properties as shown in your link will be applied when databinding. In my case, after databinding, I translate column values programatically.
Thanks in advance,
Stéphane
The grid first evaluates the filter expressions and then databinds. If you need to construct filter expressions after databding then you have to rebind the grid again after they are constructed, by calling the Rebind() method.
Kind regards,Marin
the Telerik team
I'm back to this problem :). I couldn't call Rebind because it will call myGrid_NeedDataSource...
Can you elaborate more on what type of filtering feature you are trying to achieve. Normally the grid performs filter on the underlying datasource and this is not related the data items of the control, which will allow you set filter expressions before databinding of the control
Greetings,Marin
the Telerik team
Thank you for your answer.
I'll illustrate my problem. I'm in an ASP.Net application. I registered to the events "NeedDataSource" and "ItemDataBound" of my RadGrid.
In the NeedDataSource, I bind to objects from query into my database, and store them in cache locally. The cached object is shared between my Website's users. One property on the source object is a label (by exemple : labelApple, labelCar, labelButton, ...)
In the ItemDataBound, the item's label property is translated in the user language (by exemple : labelApple->Pomme, labelCar->Voiture, LabelButton->Boutton for user n°1 in french, and labelApple->Apfel, labelCar->Auto, labelButton->Taste for user n°2 in german).
My LabelColumn need filter functionnality, and if I apply "Pomme" filter, it doesn't find any row, because the datasource contains "labelApple".
I think that I need to apply filter after the ItemDataBoud event, but before paging.
Do you understand my problem and my question ?
Thanks in advance, regards.
In case you use the default filtering feature of the grid, enabled by setting AllowFilteringByColumn to true, you can handle the ItemCommand event of the grid and there change the text in the filter textbox. Then in the Page_PreRender event you should set back the original text entered by the user.
I have shown this approach in the attached sample page. There when you enter any value the grid will filter by the hardcoded string "Name4" and the original value will be persisted in the filter textbox.
I hope this helps.
Marin
the Telerik team