把jqGrid的性能在一个共同的变量,并重新使用它们? [英] put jqgrid properties in a common variable and reuse them?

查看:170
本文介绍了把jqGrid的性能在一个共同的变量,并重新使用它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个ASP.NET网页10 jqgrids和他们每个人给用户显示不同的数据。

除了colNames,colModel,寻呼机和sortname性能,所有其他属性相同。看到我的code以下,

 数据类型:本地,
        MTYPE:GET,
        cmTemplate:{排序:真实的,可调整大小:真正},
        高度:'自动',
        altRows:真实,
        altclass:'',
        pgbuttons:假的,
        pgtext:,
        GridView控件:真实,
        loadonce:真实,
        shrinkToFit:假的,
        寻呼机:gridPager,
        AUTOEN code:真的,
        sortname:'ID',
        宽度:$('。电网包装)宽() - 20日。
        emptyrecords:没有找到记录,
        viewrecords:真实,
        排序顺序:递减,
        scrollrows:真实,
        loadui:禁用,
        toppager:真实,

是否有可能把所有的上述性质的公共变量和重用变量在所有的10个不同网格的?

我们的想法是节省一些空间,并在一个地方的变化。

请注意:我使用的jqGrid插件4.6.0

解决方案应用:

增加了以下code到我的js文件的顶部并删除所有的10 jqgrids相同的属性。伟大的工作!

  //默认值
$ .extend($。jgrid.defaults,{
    数据类型:本地,
    MTYPE:GET,
    cmTemplate:{排序:真实的,可调整大小:真正},
    高度:'自动',
    altclass:'',
    pgbuttons:假的,
    pgtext:,
    GridView控件:真实,
    loadonce:真实,
    shrinkToFit:假的,
    AUTOEN code:真的,
    emptyrecords:没有找到记录,
    viewrecords:真实,
    排序顺序:递减,
    scrollrows:真实,
    loadui:禁用
});


解决方案

是的,你可以使用jQuery做到这一点。
jquery.extend
只要把那些在一个对象defaultOptions所有jqGrids相同的属性。
然后,你可以指定在specificOptions一定的jqGrid的具体方案。下面的功能将合并到具体defaultOptions。
如果specificOptions对象包含一个属性,也是defaultOptions对象,那么它会覆盖它,
否则将其添加到选择的对象。

  VAR选项= $ .extend(真,defaultOptions,specificOptions);

I have 10 jqgrids in an ASP.NET webpage and each of them display different data to the user.

Except colNames, colModel, pager and sortname properties, all other properties the are same. See my code below,

  datatype: "local",
        mtype: "GET",
        cmTemplate: { sortable: true, resizable: true },
        height: 'auto',
        altRows: true,
        altclass: '',
        pgbuttons: false,
        pgtext: "",
        gridview: true,
        loadonce: true,
        shrinkToFit: false,
        pager: gridPager,
        autoencode: true,
        sortname: 'Id',
        width: $('.grid-wrapper').width() - 20,
        emptyrecords: 'No records found',
        viewrecords: true,
        sortorder: "desc",
        scrollrows: true,
        loadui: 'disable',      
        toppager: true,

Is it possible to put all of the above properties in a common variable and reuse the variable in all the 10 different grid's?

The idea is to save some space and make the changes in one place.

Note: I am using jqgrid plugin 4.6.0.

Solution Applied:

Added the following code to the top of my js file and removed the same properties from all the 10 jqgrids. Working great!

//DEFAULTS
$.extend($.jgrid.defaults, {
    datatype: "local",
    mtype: "GET",
    cmTemplate: { sortable: true, resizable: true },
    height: 'auto',
    altclass: '',
    pgbuttons: false,
    pgtext: "",
    gridview: true,
    loadonce: true,
    shrinkToFit: false,
    autoencode: true,
    emptyrecords: 'No records found',
    viewrecords: true,
    sortorder: "desc",
    scrollrows: true,
    loadui: 'disable'
});

解决方案

Yes you can do it using jQuery. jquery.extend Just put the properties that are the same in all jqGrids in one object defaultOptions. Then you can specify the specific options for the certain jqgrid in specificOptions. The below function will merge specific into defaultOptions. If specificOptions object contains a property that is also in defaultOptions object, then it will override it, otherwise it will add it to the options object.

var options= $.extend( true, defaultOptions, specificOptions);

这篇关于把jqGrid的性能在一个共同的变量,并重新使用它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆