UPDATED:
Starting with version 14.2, GridView provides the built-in Search / Find Panel functionality with the capability to locate it outside grid boundaries. This allows accomplishing a similar task with less effort and does not require so much extra code. See the ASP.NET Data Grid: Enhancements post to learn more about this new functionality.
This example illustrates how to highlight/select rows according to search criteria via a custom MVC GridView callback.
- Define an external filter editor (for example, the ButtonEdit with a single button);
- Handle the client-side ASPxClientButtonEdit.ButtonClick event;
- Perform a custom GridView callback via the client-side ASPxClientGridView.PerformCallback method;
- Pass the editor's value as a parameter;
- Handle the GridViewSettings.CustomActionRouteValues.Action method and retrieve the passed parameter. In general, it is possible to use the Action method specified for all GridView callbacks (GridViewSettings.CallbackRouteValues.Action). The illustrated technique allows handling a custom GridView's callback within a separate Action method, whose signature can be different. Usually, custom callbacks are used for changing the GridView's state programmatically in a custom manner;
- Pass the retrieved value to the GridView's PartialView via the ViewData key;
- Handle the GridViewSettings.BeforeGetCallbackResult event: if the ViewData key exists, iterate trough GridView rows and select the required one via the MVCxGridView.Selection API.
Added By: jlin at: 2/27/2015 2:15:25 PM
Starting with version 14.2, GridView provides the built-in Search / Find Panel functionality with the capability to locate it outside grid boundaries. This allows accomplishing a similar task with less effort and does not require so much extra code. See the ASP.NET Data Grid: Enhancements post to learn more about this new functionality.
This example illustrates how to highlight/select rows according to search criteria via a custom MVC GridView callback.
- Define an external filter editor (for example, the ButtonEdit with a single button);
- Handle the client-side ASPxClientButtonEdit.ButtonClick event;
- Perform a custom GridView callback via the client-side ASPxClientGridView.PerformCallback method;
- Pass the editor's value as a parameter;
- Handle the GridViewSettings.CustomActionRouteValues.Action method and retrieve the passed parameter. In general, it is possible to use the Action method specified for all GridView callbacks (GridViewSettings.CallbackRouteValues.Action). The illustrated technique allows handling a custom GridView's callback within a separate Action method, whose signature can be different. Usually, custom callbacks are used for changing the GridView's state programmatically in a custom manner;
- Pass the retrieved value to the GridView's PartialView via the ViewData key;
- Handle the GridViewSettings.BeforeGetCallbackResult event: if the ViewData key exists, iterate trough GridView rows and select the required one via the MVCxGridView.Selection API.
Question Comments
Added By: jlin at: 2/27/2015 2:15:25 PM
For me, it worked better handling the selection in the PreRender event versus BeforeGetCallbackResult. BeforeGetCallbackResult was not getting called.