jqGrid filterToolbar search

前端 未结 1 553
醉话见心
醉话见心 2021-02-11 06:15

In trying to implement a filterToolbar search in jquery, but when I write in the textbox it doesnt send the value, the search field nor the operator: I used an exam

相关标签:
1条回答
  • 2021-02-11 07:08

    You use the option stringResult: true of the toolbarfilter. In the case the full filter will be encoded in filters option (see here). Additionally there are no ignoreCase option of toolbarfilter method. There are ignoreCase option of jqGrid, but it works only in case of local searching.

    So you have to change the server code to use filters parameter or to remove stringResult: true option. The removing of stringResult: true could be probably the best way in your case because you have only one searchable column. In the case you will get one additional parameter on the server side: examen. For example if the user would type physic in the only searching field the parameter examen=physic will be send without of any information about the searching operation. If you would need to implement filter searching in more as one column and if you would use different searching operation in different columns you will have to implement searching by filters parameter.

    UPDATED: I wanted to include some general remarks to the code which you posted. You will have bad performance because of the usage

    $("#"+id+ " td:eq(1)", grid[0])
    

    The problem is that the web browser create internally index of elements by id. So the code $("#"+id+ " td:eq(1)") can use the id index and will work quickly. On the other side if you use grid[0] as the context of jQuery operation the web browser will be unable to use the index in the case and the finding of the corresponding <td> element will be much more slowly in case of large number rows.

    To write the most effective code you should remind, that jQuery is the wrapper of the DOM which represent the page elements. jQuery is designed to support common DOM interface. On the other side there are many helpful specific DOM method for different HTML elements. For example DOM of the <table> element contain very helpful rows property which is supported by all (even very old) web browsers. In the same way DOM of <tr> contains property cells which you can use directly. You can find more information about the subject here. In your case the only thing which you need to know is that jqGrid create additional hidden row as the first row only to have fixed width of the grid columns. So you can either just start the enumeration of the rows from the index 1 (skipping the index 0) or verify whether the class of every row is jqgrow. If you don't use subgrids or grouping you can use the following simple code which is equivalent your original code

    loadComplete: function() {
        var i, rows = this.rows, l = rows.length;
    
        for (i = 1; i < l; i++) { // we skip the first dummy hidden row
            $(rows[i].cells(1)).tooltip({
                content: function(response) {
                    var rowData = grid.jqGrid('getRowData',this.parentNode.id);
                    return rowData.descripcion;
                },
                open: function() {
                    $(this).tooltip("widget").stop(false, true).hide().slideDown("fast");
                },
                close: function() {
                    $(this).tooltip("widget").stop(false, true).show().slideUp("fast");
                }
            }).tooltip("widget").addClass("ui-state-highlight");
        }
    }
    
    0 讨论(0)
提交回复
热议问题