简体   繁体   English

JQGrid - 冷冻柱 - 冷冻柱到网格的右端

[英]JQGrid - frozen column - freezing column to right end of the grid

Is it possible to freeze last column to the right side of the grid? 是否可以将最后一列冻结到网格的右侧?

All the demos that I came across shows freezing 1st or 1st & 2nd column to left side of the grid. 我遇到的所有演示都显示将第1或第1和第2列冻结到网格的左侧。

I tried using frozen:true property to only last column in colModel, but its not working. 我尝试使用frozen:true属性只在colModel中的最后一列,但它不起作用。

The current implementation of frozen columns in jqGrid don't allows to freeze last columns to the right side of the grid. jqGrid中当前冻结列的实现不允许将最后一列冻结到网格的右侧。 So I don't see any simple way to implement your requirements in jqGrid. 所以我没有看到在jqGrid中实现您的需求的任何简单方法。

The reason of the complexity is in the implementation of frozen columns in jqGrid. 复杂性的原因在于jqGrid中冻结列的实现。 The method setFrozenColumns examine colModel from the left (from the first index of the colModel array) at the beginning (see the part of the source code). 该方法setFrozenColumns检查colModel 从左侧 (从所述第一折射率colModel阵列)在开始(见部分的源代码)。 It finds the max index of colModel which have frozen: true property and then makes the copy of the columns of the grid in the separate div. 它找到已frozen: truecolModel的最大索引frozen: true属性,然后在单独的div中创建网格列的副本 In other words jqGrid take in considerations only first columns of colModel which have frozen: true property . 换句话说,jqGrid 考虑colModel第一列,它们具有frozen: true属性 All other properties which have frozen: true will be ignored. frozen: true所有其他属性frozen: true将被忽略。 Then jqGrid creates always the div with left frozen columns only . 然后jqGrid始终只创建左冻结列的div So the usage of frozen columns on the right side of the grid not provided. 因此,未提供网格右侧的冻结列的使用。

You are seeing all demos to be freezing only left side columns, because it simply is not possible with jqGrid to freeze right hand side columns or columns that are not adjacent (Try freezing columns 1 and 3 but not 2, this will freeze only column 1. Similarly freezing columns 1, 2 and 4 but not 3 will freeze only columns 1 & 2). 您看到所有演示仅冻结左侧列,因为jqGrid无法冻结右侧列或不相邻的列(尝试冻结列1和3但不是2,这将仅冻结列1类似地,冻结第1,2和4列而不是第3列将仅冻结第1列和第2列。

Below the code snippet from jqGrid, which imposes such a rule (refer while loop with comment from left, no breaking frozen ). 在jqGrid的代码片段下面,它强制执行这样的规则(引用带有from left, no breaking frozen注释的while循环from left, no breaking frozen )。 If you are serious about allowing a right-side column to be frozen, you can try to make modifications to the jqGrid code as per your requirements. 如果您认真考虑允许冻结右侧列,您可以尝试根据您的要求修改jqGrid代码。

setFrozenColumns : function () {
        return this.each(function() {
            if ( !this.grid ) {return;}
            var $t = this, cm = $t.p.colModel,i=0, len = cm.length, maxfrozen = -1, frozen= false;
            // TODO treeGrid and grouping  Support
            if($t.p.subGrid === true || $t.p.treeGrid === true || $t.p.cellEdit === true || $t.p.sortable || $t.p.scroll )
            {
                return;
            }
            if($t.p.rownumbers) { i++; }
            if($t.p.multiselect) { i++; }

            // get the max index of frozen col
            while(i<len)
            {
                // from left, no breaking frozen
                if(cm[i].frozen === true)
                {
                    frozen = true;
                    maxfrozen = i;
                } else {
                    break;
                }
                i++;
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM