如何删除闪烁坚持远程填充的jqGrid树节点 [英] How to remove flashing on persisting remotely populated jqgrid tree node

查看:112
本文介绍了如何删除闪烁坚持远程填充的jqGrid树节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jqGrid的树节点使用服务器JSON数据读取。单击节点从服务器读取子节点。
低于code的用途是当页面加载恢复开树节点。
只有单个节点在树总是打开。
控制器assings节点ID为autoClicked阵列和gridComplete打开使用此路径节点。
这将导致在页面加载网格flasinging因为多个服务器的请求电网打造专业化多次。
如何禁用电网闪烁?
是否有可能prevent多个jqGrid的建筑,仅显示发现的jqGrid树?

在回答
发送扩展的TreeGrid节点中的cookie
适用于只有充分填充网格。

  VAR autoClicked = [<%= Model.Path()%]的计算值;
$(函数(){
    VAR电网= $(#树网);
    grid.jqGrid({
        gridComplete:功能(){
            的setTimeout(函数(){
                变种的id = autoClicked.shift();
                VAR RDATA = grid.getGridParam(数据);
                VAR数据= NULL;
                对于(VAR I = 0; I< rData.length;我++){
                    如果(ID == RDATA [I] .ID){
                        数据= RDATA [I]
                        打破;
                    }
                }                如果(数据== NULL)
                    返回;
                grid.expandRow(数据);
                grid.expandNode(数据);
            },0);        },
        网址:'<%= RESOLVEURL(〜/存储/的GridData)%>,
        数据类型:JSON
        MTYPE:POST,
        高度:自动,
        loadui:禁用,
        treeGridModel:邻居
        colModel:
                {名:ID,宽度:1,隐蔽性:真实,键:真正},
                {名:菜单,上课:handcursor},
                {名:URL,宽度:1,隐:真正}
            ]
        autowidth:真实,
        TreeGrid的:真实,
        ExpandColumn:菜单
        的rowNum:200,
        ExpandColClick:真实,
        onSelectRow:功能(ROWID){
            VAR treedata = grid.jqGrid('getRowData',ROWID);
            window.location的= treedata.url;
        }
    }
            );
});

控制器:

 公共字符串路径()
    {
        Artomlii节点= Artomliik;
        字符串资源= node.Artomaliik.ToString();
        而(!Core.IsNullOrWhiteSpace(node.Treeparent))
        {
            //获取父节点
            节点= MyDataContext.ExecQuery< Artomlii>(@SELECT * FROM artomlii那里treeorder = {0},node.Treeparent).FirstOrDefault();
            如果(节点== NULL)
                打破;
            RES = node.Artomaliik.ToString()+,+资源;
        }
        返回水库;
    }


解决方案

在你的地方我会解决的另一种方式的问题。

我会发送到服务器 POSTDATA 其中包含应扩大节点列表附加参数。

在这种情况下,服务器将放置的所有要求的节点的响应中。 扩大隐藏列的值可以设置为真正或者直接在服务器响应或在客户端上的 beforeProcessing 回调中,我在您参考答案。

在路上你会正是您需要的相同的结果。网格的填充物​​会因消除不必要的往返的更迅速。闪烁将被删除,因为在树网格中的所有行会,因为 GridView控件的使用情况填写毕其功于一役:真正的这是默认树网格在当前实现jqGrid的的。

jqGrid tree nodes are read from server using json data. Click in node reads child nodes from server. Code below is used to restore opened tree node if page is loaded. Only single node is opened always in tree. Controller assings node ids to autoClicked array and gridComplete opens nodes using this path. This causes grid flasinging on page load since multiple server requests buid grid multiple times. How to disable grid flashing ? Is it possible to prevent multiple jqGrid building and show only find jqGrid tree ?

Answer in Send expanded TreeGrid Nodes in cookie works for fully populated grid only.

var autoClicked=[<%= Model.Path() %>];
$(function () {
    var grid = $("#tree-grid");
    grid.jqGrid({
        gridComplete: function () {
            setTimeout(function () {
                var id = autoClicked.shift();
                var rData = grid.getGridParam('data');
                var data = null;
                for (var i = 0; i < rData.length; i++) {
                    if (id == rData[i].id) {
                        data = rData[i];
                        break;
                    }
                }

                if (data == null)
                    return;
                grid.expandRow(data);
                grid.expandNode(data);
            }, 0);

        },
        url: '<%= ResolveUrl("~/Store/GridData")%>',
        datatype: "json",
        mtype: "POST",
        height: "auto",
        loadui: "disable",
        treeGridModel: "adjacency",
        colModel: [
                { name: "id", width: 1, hidden: true, key: true },
                { name: "menu", classes: "handcursor" },
                { name: "url", width: 1, hidden: true }
            ],
        autowidth: true,
        treeGrid: true,
        ExpandColumn: "menu",
        rowNum: 200,
        ExpandColClick: true,
        onSelectRow: function (rowid) {
            var treedata = grid.jqGrid('getRowData', rowid);
            window.location = treedata.url;
        }
    }
            );
});

controller:

    public string Path()
    {
        Artomlii node = Artomliik;
        string res = node.Artomaliik.ToString();
        while (!Core.IsNullOrWhiteSpace(node.Treeparent))
        {
            // retrieve parent node
            node = MyDataContext.ExecQuery<Artomlii>(@"select * from artomlii where treeorder={0}", node.Treeparent).FirstOrDefault();
            if (node == null)
                break;
            res = node.Artomaliik.ToString() + "," + res;
        }
        return res;
    }

解决方案

On your place I would solve the problem in another way.

I would send to the server in postData an additional parameter which contains the list of nodes which should be expanded.

In the case the server will place all requested nodes in the response. The value of "expanded" hidden column can be set to true either directly in the server response or on the client side in the beforeProcessing callback in the way which I described in the answer which you referenced.

In the way you would have exactly the same results which you need. The filling of the grid will be more quickly because of elimination of unneeded round-trips. The flashing will be removed because all the rows in the tree grid will be filled "at once" because of the usage of gridview: true which is default for Tree Grids in the current implementation of jqGrid.

这篇关于如何删除闪烁坚持远程填充的jqGrid树节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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