This is a migrated thread and some comments may be shown as answers.

[Solved] Issues implementing Search functionality using grid different binding approaches.

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Raja
Top achievements
Rank 1
Raja asked on 24 Mar 2011, 09:02 AM
Hi,

    I am implementing search functionality in my ASP.NET MVC 3 application. Following are the requirements.
    
  1. User must be allowed to set search criteria.  Search Criteria controls are not Strongly Binded.
  2. Upon clicking search button ajax call must be made to action to which users search criteria values must be passed and the results must be populated in the grid view. 
  3. Paging and Sorting must be available on the results.

To achieve above functionality i used two approaches
 

  1. Ajax Binding:- http://demos.telerik.com/aspnet-mvc/razor/grid/ajaxbinding I can't figure out how to pass route values to the search action method.Since Search Criteria controls are not Strongly Binded.
  2. Twitter Binding: http://demos.telerik.com/aspnet-mvc/razor/grid/externalservicetwitter  Paging and sorting are not working using this method.

Please let me know if i am doing anything wrong. Any solution to the above problem will be greatly appreciated.

Thank you,
Raja.

1 Answer, 1 is accepted

Sort by
0
Raja
Top achievements
Rank 1
answered on 24 Mar 2011, 07:12 PM
I could solve this by using grid Ajax binding and passing the route values by the client Events example is available in the telerik documentation. http://www.telerik.com/help/aspnet-mvc/changes-and-backward-compatibility.html

function dataBinding(args) 
    {
        args.data = $.extend(args.data, 
                              
                                searchFor: $('#SearchCriteria').val(),
                                searchForValue:$('#SearchCriteriaValue').val()
                              }
    }
@{
  Html.Telerik().Grid(Model).Name("SearchResults")
            .DataBinding(dm => dm.Ajax()
                         .Select("Search", "CallSearch", new { searchForTemp = ViewData["SearchCriteriaValue"] })).ClientEvents(cEvnt => cEvnt.OnDataBinding("dataBinding").OnRowDataBound("onRowDataBound"))
            .Pageable()
            .Sortable()
            .Filterable()
            .Render();
        }


Tags
Grid
Asked by
Raja
Top achievements
Rank 1
Answers by
Raja
Top achievements
Rank 1
Share this question
or