Custom search with SearchModel...

Sep 27, 2011 at 7:41 PM


I added a div above my grid, like that :

<div id="filter-grid"></div>
So, I added that javascript to enable JQGrid search on that div :
 $('#filter-grid').filterGrid('#grid', {
        buttonclass: 'width-6',
        gridModel: false,
        buttonclass: 'width-6',
        enableSearch: 'false',
        filterModel: [{
            label: '',
            name: 'search',
            stype: 'text'
It works fine using that Controller method:
public ActionResult List(int page, int rows, string sidx, string sord, string search)
But I´d like to know how integrate that with SearchModel parameter... Is it possible?
Sep 28, 2011 at 4:37 AM

Follow is my code. 

public ActionResult List(SearchModel searchModel)
            var ctx = new NorthwindDataContext();

            var q = ctx.Products;

            var data = q.ToGridData(searchModel, GridModel.ProductColumns);

            return Json(data, JsonRequestBehavior.AllowGet);

Use the Method ToGridData which the controls provided.