如何做jqGrid的外部滤波 [英] How to do external filtering on jqgrid

查看:150
本文介绍了如何做jqGrid的外部滤波的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的ASP.net网络aplication实现jqGrid的,我不希望使用的jqGrid提供内置的过滤。所以,我想用外部滤波的。

I am implementing jqGrid in my ASP.net web aplication, and I don't want to use the inbuilt filtering provided by jqGrid. So, I thought of using external filtering.

我将有一个文本框。只要用户输入一个值,单击该按钮上的过滤器,我想重新加载网格。我使用的服务器端分页,我必须做服务器端进行过滤。

I will have a textbox. As soon as a user enters a value and clicks on the button filter, I would like to reload the grid. I am using server side pagination and I must do server side filtering.

我对此一些帖子,但我没能找到一个坚实的例子来证明这一点。

I have some posts regarding this, but I was not able to find a solid example to demonstrate this.

我不知道过滤器值是如何收到在C#code做的过滤。

I also dont know how the filter value is recieved in the C# code to do the filtering.

推荐答案

您可以用 POSTDATA 做参数的jqGrid,并通过自己的价值观,以过滤和刷新电网

You can do it with postData parameter in jQGrid and pass your own values to filter and refresh grid

$(document).ready(SearchPatients);

function SearchPatients() {
    'use strict';
    jQuery("#patient-search-grid").jqGrid({
    url: '/Patient/Search/',
    datatype: 'json',
    mtype: 'POST',
    postData: { ID:function(){return $("#txtbkgID").val();} },
    //postData:{search:function () { return getSearchPostData() } }, 
    colNames: [{'Id','Pid','FullName'}],
    colModel: [
               { name: 'Id', index: 'Id',hidden: true },
               { name: 'PatientIdentifier',index: 'PatientIdentifier'},
               { name: 'FullName', index: 'FullName'}
             ],
    height: "100%",
    pager: '#patient-search-pager',
    rowNum: 10,
    rowList: [10, 30, 50],
    sortname: 'Id',
    sortorder: 'desc',
    viewrecords: true,
    caption: "Search Results"

  }

function getSearchPostData(){
 var searchData = {};
 searchData.PatientIdentifier = $('#patient-identifier').val();
 searchData.FirstName = $('#first-name').val();
 searchData.LastName = $('#last-name').val();   
 return JSON.stringify(searchData);
}

在控制器中添加可选参数ID

In Controller add optional parameter ID

    [HttpPost]
    public JsonResult Search(string ID)
    {
      //Request.Params["ID"] also will work

    }

这篇关于如何做jqGrid的外部滤波的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆