How to get jqGrid Search column type when doing a search?

I am using jqGrid 3.8.2 on ASP.net and I am declaring a fairly simple jqGrid configuration. The data is displayed correctly, and I can search for several conditions through the search dialog ... no problem.

The problem is that in cases where I am looking for a value that is not a string, I now need the data type in this column. Although I have the "stype" option in the columns to say exactly the type that I expect there, this configuration is not passed when querystring is requested when performing a search.

json I get a request for 2 search conditions: {"GroupOp": "AND", "rules": [{"field": "EntityId", "op": "GT", "data": "3"}, { "field": "EntityId", "op": "l", "data": "8"}]}

Note that the value of "data" is always enclosed in quotation marks, but the value is numeric, and this column has a value of type "int" (I can not find anything about how to use this)

The bottom line is that when I execute the query, I cannot pass information about the type of the column.

How can I do that?

Here is my grid declaration:

    $('#EntityListGrid').jqGrid({
        url: 'my url',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['ID', 'Name', 'Actions'],
        colModel: [
        { name: 'EntityID', index: 'EntityID', width: 50, align: 'left', resizable: true, sortable: true, stype: 'int' },
        { name: 'Name', index: 'Name', width: 250, align: 'left', resizable: true, sortable: true, stype: 'string' },
        { name: 'act', index: 'act', width: 75, sortable: false },
        ],
        pager: $('#EntityListGridPager'),
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: 'EntityID',
        sortorder: 'desc',
        viewrecords: true,
        imgpath: '',
        caption: 'Entities',
        width: EntityListGridWidth,
        height: 400,
        gridComplete: function () {
            var ids = jQuery("#EntityListGrid").jqGrid('getDataIDs');
            var editImageUrl = 'edititem.GIF';
            for (var i = 0; i < ids.length; i++) {
                var cl = ids[i];

                ce = "<img src='" + editImageUrl + "'  onclick='EditEntity(" + cl + "); return false;' />";
                ce2 = "<input type='button' value='details' src='" + editImageUrl + "' onclick='EditEntity(" + cl + "); return false;' />";
                //jQuery("#EntityListGrid").jqGrid('setRowData', ids[i], { act: ce2 });
                $("#EntityListGrid").setRowData(ids[i], { act: ce2 });
            }
        }
        //});
    }).navGrid('#EntityListGridPager', { search: true, edit: false, add: false, del: false, searchtext: "Search" }, {}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true });
+3
source share
1 answer

stype : "" "". stype .

, , , . , , DateTime, Int32, Int64, Double - .

+3

Source: https://habr.com/ru/post/1789600/


All Articles