0

我正在使用 struts2-jquery-jqgrid 插件来构建网格。我 在这个网格上有 filter-search**h。我在列assigned_user 上有一个下拉列表,用于根据从下拉列表中选择的选项过滤网格。**我已经使用 struts 构建的网格

<s:url var="remoteurl" action="adminJsontable">
    </s:url>
    <sjg:grid
        id="gridtable"
        caption="Issue-Summary"
        dataType="json"
        href="%{remoteurl}"
        pager="true"
        gridModel="finalGridModel"
        rowList="10,20,25"
        rowNum="10"
        rownumbers="true"
        width="1250" 
        filter="true"
        filterOptions="{stringResult :false,
                        searchOnEnter : true,
                        enableClear : true,
                        autosearch : false
                       }"
        loadonce="false"

    >
        <sjg:gridColumn  name="issue_id"  id="issueId"   index="id" title="Issue-ID" formatter="integer" formatoptions="{thousandsSeparator: ''}"  sortable="false" width="100"/>
        <sjg:gridColumn name="issue_description" index="issue_description" title="Issue-Details"  sortable="false"  width="300"/>
        <sjg:gridColumn name="issue_raised_date" index="issue_raised_date" title="Issue-Date"  formatter="date"  sortable="false"  width="100"/>

        <sjg:gridColumn  name="issue_action"  index="issue_action" title="Action"  formatter="formatLink" sortable="false"/>

        <sjg:gridColumn name="assigned_to"   index="assigned_user" key="assigned_user" title="Assigned To"   
        sortable="false"
        searchtype="select"
        search="true"
        searchoptions="{defaultSearch:'cn', dataUrl : '%{fillUser}', 
                       dataEvents: [{ type: 'change', data: { field: 'assigned_user',operation:'eq'}, fn: function(elem) { filterFunction(elem)}}]}"/>

    </sjg:grid>

我使用以下过滤此网格

function filterFunction(ele) {
    var selectedOption=$(ele.target).val();
    $.ajax({
        url: "adminJsontable?searchString=" + selectedOption + "&searchField=" + ele.data.field,
        dataType: "json",
        complete: function (jsondata, stat) { 
            if (stat=="success") {
                //here i am loading the json data as response from server
                jQuery("#gridtable")[0].addJSONData(jsondata);
            }
        }
    });
}

json-data 包含具有以下对象的列表:

public class Jgrid_Data 
{
    private String issue_id;//getters & setters
    private String issue_raised_date;
    private String issue_description;
    private String issue_status;
    private String assigned_to;

问题场景:

第一次加载 jqgrid 时,它非常棒,它是由相同的json-data加载的,即来自服务器的列表,但是当我过滤网格并使用不同的数据加载相同的集合时,jqgrid 显示没有行。为什么会这样?

更新部分:这是我的 json 数据

{
    "finalGridModel": [
        {
            "assigned_to": "neo",
            "issue_description": "Balance not Showing_OR7520180001",
            "issue_id": "2880",
            "issue_raised_date": "2012-03-05",
            "issue_status": "Assigned"
        },
        {
            "assigned_to": "neo",
            "issue_description": "Re: for accounts",
            "issue_id": "3215",
            "issue_raised_date": "2012-03-10",
            "issue_status": "Assigned"
        },
        {
            "assigned_to": "neo",
            "issue_description": "[Fwd: Transaction issue of chhatarpur M.P.csp Rohit jain",
            "issue_id": "3714",
            "issue_raised_date": "2012-03-15",
            "issue_status": "Assigned"
        },
        {
            "assigned_to": "neo",
            "issue_description": "Balance not Showing_(Sambalpur)_19_03_2012",
            "issue_id": "3995",
            "issue_raised_date": "2012-03-19",
            "issue_status": "Assigned"
        },
        {
            "assigned_to": "neo",
            "issue_description": "Fwd: issue no-103",
            "issue_id": "4003",
            "issue_raised_date": "2012-03-19",
            "issue_status": "Assigned"
        }
    ],
    "issueTrackerInstance": {
        "assigned_by": null,
        "issue_id": null,
        "issue_status": null,
        "tracked_time": null,
        "tracker_name": null,
        "tracker_status": null
    },
    "page": 1,
    "records": 10,
    "rows": 10,
    "session": {
        "filter_user": "neo",
        "userName": "admin"
    },
    "sidx": null,
    "sord": "asc",
    "stringResult": null,
    "total": 1
}

任何帮助都会很棒

4

1 回答 1

0

找到解决方案,只需将 ajax-event 从完成更改为成功。

 success: function(jsondata,stat)
  { 
  if(stat=="success") 
  {
  jQuery("#gridtable")[0].addJSONData(jsondata);//here i am loading the json data as response from server
  }
于 2013-02-28T10:23:28.640 回答