使用jqgrid treegrid无法正常工作的工具栏搜索

时间:2013-06-12 15:46:04

标签: jquery jqgrid treegrid

我的jqgrid有一个很大的问题,搜索和工具栏搜索都不起作用,这是我的代码:

$("#str_container-uiId").jqGrid({ xmlReader: { root:"structure_object", row:"node_structure", repeatitems:false, id : "node_id" }, treeReader: { level_field: "structure>level", parent_id_field: "structure>parent_id", leaf_field: "structure>leaf", expanded_field: "structure>expand" }, treeGrid: true, treeGridModel: 'adjacency', ExpandColumn: 'reference', ExpandColClick : true, url: '/audros/html/test4.xml', datatype: 'xml', mtype: 'GET', postData: { objectID: function() { return current_id; } }, colNames: ["id","hiddenID","className", "reference","","Qty","Class","Att","Verrou", "Ver.","Rev","Désignation","Modifié le","Status"], colModel: [{name:'id',index:'id', width:1,key:true,hidden:true,xmlmap:"node_id"}, {name:'hiddenID',index:'hiddenID', width:1,hidden:true,xmlmap:getNodeId}, {name: 'className',index: 'className',width: 1,hidden: true,xmlmap:"obj_classname"}, {name: 'reference',index: 'reference',width: 25,xmlmap:getRefLabel}, {name: 'linkName', index: 'linkName',width: 5, align: 'left',editable: true,hidden: false,xmlmap:function (obj) {return getLink(obj,"linkName"); }}, {name: 'qty', index: 'qty',width: 3,editable: true,xmlmap:"structure>str_qty"}, {name: 'classLabel',index: 'classLabel',width: 20,xmlmap:getClass}, {name: 'attachment',index: 'attachment',width: 5,xmlmap:getAttachment}, {name: 'verrou',index: 'verrou',width: 5,xmlmap:getVerrou}, {name: 'version',width: 3,xmlmap:"obj_version"}, {name: 'release',width: 3,xmlmap:"obj_release"}, {name: 'description',width: 10, editable:true,xmlmap:"obj_description"}, {name: 'modifDate',width: 17, editable:true,xmlmap:"obj_modificationdate"}, {name: 'statusLabel',width: 10, editable:true,xmlmap:"obj_status_label"} ],

                    gridComplete: function(){
                        $('.jqgrow').addClass('objClassName');

                        $("#str_container-uiId").trigger("reloadGrid");
                    },
                    cellEdit: true,
                    height: 'auto',
                    width: 1284,
                    pager: '#ptoolbar',
                    viewrecords: true,
                    multiselect: false

                })

$("#str_container-uiId").jqGrid('navGrid','#ptoolbar',{del:false,add:false,edit:false,search:true});
                $("#str_container-uiId").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});

我可以看到区域creteria但是当我输入角色时没有任何事情发生,如果我点击搜索btn,当我选择一个creteria也没有任何事情发生的事件。 treegrid与搜索和工具栏搜索一起使用???  请帮忙

1 个答案:

答案 0 :(得分:0)

好吧,原始的treegrid不提供搜索选项。但您可以编写自己的自定义导航搜索按钮,如下所示:

$("#grid").jqGrid('navButtonAdd', "#pagerid", {        // grid - your grid name, pagerid - your pager name
caption: "", title: "Search", buttonicon: "ui-icon-search",
onClickButton: function () {
    $("#grid").searchGrid({
        closeOnEscape: true,
        searchOnEnter: true,
        width:500,
        closeAfterSearch: true,
        sopt: ['eq','ne','lt','gt','cn','nc','bw','ew'],
        onSearch: function(){
            rowName = $('#fbox_grid .columns select'); //search field
            operator = $('#fbox_grid .selectopts');    //search option
            needle = $('#fbox_grid .data input');      //search argument
            /*some code to work with searchoptions*/
        }  
    }
}

}

您必须根据自己的需要编写自己的搜索功能。