简体   繁体   English

冻结列中的jqGrid错误

[英]jqGrid error in frozen columns

I have a grid with the first column frozen. 我有一个第一列冻结的网格。 When I move the horizontal scroll, this column in the grid´s header´s is frozen, but in the grid´s body, all the columns can be moved horizontally, the first column isn´t frozen. 当我移动水平滚动时,网格标题中的此列被冻结,但在网格的主体中,所有列都可以水平移动,第一列不会被冻结。 I´ve gone over my code a hundred of times and it´s fine. 我已经完成了我的代码一百次而且很好。 I don´t have any other css or javascript in my project, and it´s occurs in IE8, Firefox and Chrome. 我的项目中没有任何其他css或javascript,它出现在IE8,Firefox和Chrome中。 I´m working with the lastest version of jQgrid. 我正在使用最新版本的jQgrid。

Here is my code: 这是我的代码:

jQuery("#single").jqGrid({
                    data : mydata,
                    datatype : "local",
                    height : 115, //Define el alto total del listado
                    width : 650, //Define el ancho total del listado
                    colNames : [ 'Index', 'Date', 'Code', 'Amount' ], //Nombres de las cabeceras de las columnas.
                    colModel : [ {
                        name : 'item_id', // Prop. name del modelo de datos
                        index : 'item_id',
                        width : 100,
                        sorttype : 'int',
                        align: 'center',
                        frozen:true
                    }, {
                        name : 'item_date',
                        index : 'item_date',
                        width : 450,
                        formatter : 'date',
                        formatoptions : {
                            newformat : 'd/M/Y'
                        },
                        datefmt : 'd/M/Y',
                        align: 'center'

                    }, {
                        name : 'item_cd',
                        index : 'item_cd',
                        width : 400
                    }, {
                        name : 'amount',
                        index : 'amount',
                        width : 400,
                        formatter: "integer", //Define el tipo de dato. Imprescindible cuando queremos crear una celda de totales. 
                        align: 'right',     //Alineación del texto dentro de la celda.
                        editrules : {
                            edithidden : true
                        },
                        editoptions : {
                            /*disabled : 'disabled',*/
                            size : '10',
                            maxlength : '8',
                        }
                    } ],
                    rowNum : 10,
                    rowTotal : 2000,
                    rowList : [ 5, 10, 20, 30 ],
                    loadonce : true,
                    mtype : "GET",
                    rownumbers : false, // Mostrar/ocultar el nº de fila.
                    rownumWidth : 40, // Ancho de la columna que muestra el nº de fila.
                    gridview : true,
                    pager : '#psingle', //Id de la capa que contiene el paginador.
                    sortname : 'item_id', // Columna inicial sobre la que realiza la ordenación. ini
                    viewrecords : true, // Muestra/Oculta  el mensaje de: "Mostrando 1 de..." 
                    sortorder : "desc",
                    editurl : './listado.html',
                    caption : "Tabla de datos editables", //Titulo del listado.
                    align: 'center',
                    //shrinkToFit : true,
                    footerrow : true, // Activa el pie del listado. Imprescible si se quiere visualizar.
                    userDataOnFooter : true,
                    edit : {
                        top : '100px',
                        left : '100px',
                        addCaption : "Add Record",
                        editCaption : "Modificar registro",
                        bSubmit : "Modificar",
                        bCancel : "Cancelar",
                        bClose : "Cerrar",
                        saveData : "Data has been changed! Save changes?",
                        bYes : "Yes",
                        bNo : "No",
                        bExit : "Cancel"
                    },
                });

                /* Botones de edición */
                jQuery("#single").jqGrid('navGrid', '#psingle', {
                    del : true,
                    add : true,
                    edit : true
                });

                /* Activa la funcionalidad de las columnas fijas. Se usa en combinación con el atributo "frozen:true"
                    en la columna. */
                jQuery("#single").jqGrid('setFrozenColumns');

The reason of the problem is the bug in setFrozenColumns method of jqGrid. 问题的原因是setFrozenColumns方法中的错误。 If you fill jqGrid from datatype : "local" or if just the grid is already filled with data before calling of setFrozenColumns the method setFrozenColumns works incorrect. 如果从datatype : "local"填充jqGrid datatype : "local"或者如果在调用setFrozenColumns之前网格已经填充了数据,则方法setFrozenColumns工作方式不正确。 As the workaround you can include the line 作为解决方法,您可以包含该行

jQuery("#single").triggerHandler("jqGridAfterGridComplete");

directly after jQuery("#single").jqGrid('setFrozenColumns'); 直接在 jQuery("#single").jqGrid('setFrozenColumns'); 之后 jQuery("#single").jqGrid('setFrozenColumns'); . I described the problem multiple times. 我多次描述这个问题。 After the post here the bug is fixed in the code of jqGrid on github (see the fix here ). 这里发布后,错误被修复在github上的jqGrid代码中(参见此处的修复)。 So you can remove the line later if you would use new version of jqGrid (version higher as the current 4.5.2). 因此,如果您要使用新版本的jqGrid(版本高于当前版本4.5.2),您可以稍后删除该行。

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

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