سؤال

I'm using jqGrid 3.8.2 on ASP.net and I'm declaring a pretty simple jqGrid configuration. The data is showing correctly and I'm able to search by multiple conditions through the search dialog... no problem.

The problem is that in the cases where I'm searching for a value that is not a string I need to now the type of the data on that column. Although I have an 'stype' option on the columns to say exactly the type I'm expecting there, this configuration isn't being passed on the request querystring when I perform a search.

The json I'm getting on the request for 2 search conditions is this: {"groupOp":"AND","rules":[{"field":"EntityID","op":"gt","data":"3"},{"field":"EntityID","op":"lt","data":"8"}]}

Notice that the 'data' value is always enclosed in quotes but the value is numeric and that column have the stype set to 'int' (I can't find anything on how to use this)

Bottom line is that I when I do the request I have no way of passing the information about the type of the column.

How can it be done?

Here's 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 });
هل كانت مفيدة؟

المحلول

How you can read in the documentation stype support only two values: "text" and "select". The stype will be used only to build different controls in the searching dialog.

All "data" elements wich will be sent to the server are encoded always as strings and the server have to convert the data to the corresponding data type. For example if you use column as the date or integer the server is responsible to convert the data to DateTime, Int32, Int64, Double or some other type.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top