TypeError:无法读取JQGrid中Undefined或Null引用的“stype”

时间:2017-08-16 07:09:30

标签: jqgrid

我希望过滤以列表格式动态生成的数据。如果我 使用了SearchOptions事件然后它抛出 TypeError的错误:无法读取未定义或空引用的“stype”。任何人都可以为我提供解决方案。网格模型如下所示:

 jQuery("#list2").jqGrid({
    url: '/LocaleRate/LocaleRates',   
    datatype: "json",
    colModel: [
        { name: 'Id', hidden: true },
        {
            name: 'SourceLocaleId', index: 'SourceLocaleName', width: 130, align: "left", editable: true, edittype: "select", formatter: 'select', editoptions: { value: LocaleList }, editrules: { required: true ,          stype: 'select', searchoptions: { sopt: ['eq', 'ne'], value: LocaleList 
        },
        {
            name: 'LocaleId', index: 'LocaleName', width: 90, align: "left", editable: true, edittype: "select", formatter: 'select', editoptions: { value: LocaleList }, editrules: { required: true }, stype: "select", searchoptions: { value: LocaleList }
        },
        {
            name: 'CompanyId', index: 'CompanyName', editable: true, width: 100, editable: true, edittype: "select", formatter: 'select',
            editoptions: {value: CompanyList}, editrules: { required: true},
            stype: "select", searchoptions: { value: CompanyList }
        },
        { name: 'VDBID', id: 'VDBID', editable: true, width: 90, editrules: { required: true }, editoptions: { readonly: "readonly" } },
        {
            name: 'CurrencyId', index: 'CurrencyName', width: 100, editable: true, edittype: "select", formatter: 'select', editoptions: { value: CurrencyList }, editrules: { required: true },
            stype: "select", searchoptions: { value: CurrencyList }
        },
        { name: 'HourRate', id: 'HourRate', editable: true, width: 130, editrules: { required: true } },
        { name: 'PageRate', id: 'PageRate', editable: true, width: 90, editrules: { required: true } },
        { name: 'WordRateExact', id: 'WordRateExact', editable: true, width: 130, editrules: { required: true } },
        { name: 'WordRateDuplicate', id: 'WordRateDuplicate', editable: true, width: 140, editrules: { required: true } },
        { name: 'WordRateFuzzy', id: 'WordRateFuzzy', editable: true, width: 130, editrules: { required: true } },
        { name: 'WordRateNew', id: 'WordRateNew', editable: true, width: 90, editrules: { required: true } },
        { name: 'MinimumPageCount', id: 'MinimumPageCount', editable: true, width: 130, editrules: { required: true } },
        { name: 'MinimumWordCount', id: 'MinimumWordCount', editable: true, width: 130, editrules: { required: true } },
        { name: 'WordRateExactComplex', id: 'WordRateExactComplex', editable: true, width: 150, editrules: { required: true } },
        { name: 'MinimumCharge', id: 'MinimumCharge', editable: true, width: 90, editrules: { required: true } },
        { name: 'WordRateDuplicateComplex', id: 'WordRateDuplicateComplex', editable: true, width: 150, editrules: { required: true } },
        { name: 'WordRateFuzzyComplex', id: 'WordRateFuzzyComplex', editable: true, width: 90, editrules: { required: true } },
        { name: 'WordRateNewComplex', id: 'WordRateNewComplex', editable: true, width: 90, editrules: { required: true } },
        { name: 'FirstProofRate', id: 'FirstProofRate', editable: true, width: 90, editrules: { required: true } },
        { name: 'WordRateHighFuzzy', id: 'WordRateHighFuzzy', editable: true, width: 90, editrules: { required: true } },
        { name: 'WordRateHighFuzzyComplex', id: 'WordRateHighFuzzyComplex', editable: true, width: 90, editrules: { required: true } },
        { name: 'DTPVendorHourRate', id: 'DTPVendorHourRate', editable: true, width: 90, editrules: { required: true } },
        { name: 'DTPVendorPageRate', id: 'DTPVendorPageRate', editable: true, width: 90, editrules: { required: true } },
        { name: 'VDBPriceLineID', id: 'VDBPriceLineID', editable: true, width: 90, editrules: { required: true } },
        { name: 'MTRate', id: 'MTRate', editable: true, width: 90, editrules: { required: true } },
        { name: 'DTPClientHourRate', id: 'DTPClientHourRate', editable: true, width: 90, editrules: { required: true } },
        {
            name: 'IsActive', editable: true, width: 40, edittype: "checkbox", editoptions: { value: "True:False" }
        }
    ],
    rowNum: 10,
    rowList: [10, 20, 30],
    pager: '#pager',
    loadonce: true,
    sortname: 'id',
    height: "auto",
    width: 2000,
    viewrecords: true,
    sortorder: "desc",
    caption: "JSON Example",
    jsonReader: {
        root: "rows",
        page: "page",
        total: "total",
        records: "records",
        repeatitems: false,
        id: "0"
    },
    autowidth: true,
});

jQuery("#list2").jqGrid('filterToolbar', {
    stringResult: true,
    searchOnEnter: false,     
});

参考上面的代码,我想要SourceLocaleId,LocaleID,CompanyId&的过滤器。 CurrencyId字段,包含动态数据。

1 个答案:

答案 0 :(得分:0)

在这里,我已经从列表方式替换了具有来自' SourceLocaleName'的动态数据的每列的索引值。到了SourceLocaleId'。