简体   繁体   English

如何禁用jqgrid中已发布行的内联和表单编辑

[英]How to disable inline and form editing for posted rows in jqgrid

I'm looking for a way to disable editing of jqGrid rows where isPosted column has value true. 我正在寻找一种方法来禁用对isPosted列的值为true的jqGrid行的编辑。

Both form and inline editing with actions formatter or double clicking in row are used. 使用动作格式化程序或双击行进行表格和内联编辑。 All kinds of editing needs to be disabled. 需要禁用所有类型的编辑。 I tried code below in jqGrid loadcomplete. 我在jqGrid loadcomplete中尝试了以下代码。

This does not disable form editing. 这不会禁用表单编辑。 Also double click in posted row shows save and cancel buttons (all columns are in readonly mode). 同样,在已发布的行中双击也会显示“保存”和“取消”按钮(所有列均处于只读模式)。

How to disable all kind of row editing for posted rows ? 如何禁用发布行的所有行编辑? jqGrid is populated from remote jqson data. jqGrid是从远程jqson数据填充的。

  loadCompete: function () {
    var
      postedCol = getColumnIndexByName($grid, 'isPosted'),
      cRows = $grid[0].rows.length,
      iRow,
      row,
      className,
      isPosted,
      cm = $grid.jqGrid('getGridParam', 'colModel'),
      l,
      iActionsCol = getColumnIndexByName($grid, '_actions');

    l = cm.length;
    for (iRow = 0; iRow < cRows; iRow = iRow + 1) {
            row = $grid[0].rows[iRow];
            className = row.className;
            isPosted = false;
            if ($.inArray('jqgrow', className.split(' ')) > 0) {
              isPosted = $(row.cells[postedCol]).find(">div>input:checked").length > 0;
              if (isPosted) {
                    if ($.inArray('jqgrid-postedrow', className.split(' ')) === -1) {
                        // todo: how to disable row editing and inline edit actions buttons.
                        // why those two lines do not disable
                        row.className = className + ' jqgrid-postedrow not-editable-row';
                        $(row.cells[iActionsCol]).attr('editable', '0'); 
                        $(row.cells[iActionsCol]).find(">div>div.ui-inline-del").hide();
                        $(row.cells[iActionsCol]).find(">div>div.ui-inline-edit").hide();
                    }
                }
            }
        }


css file:

.jqgrid-postedrow
{
    background-color: #FFFFD0;
    background-image: none;
}

@Andrus, well you can check on gridComplete or LoadComplete about the value of isPosted, if it is true simply hide the edit buttons using jquery, and you can get the id of those buttons using developer tools right? @Andrus,那么您可以检查isComped的值是否在gridComplete或LoadComplete上,如果为true,则使用jquery隐藏编辑按钮,然后可以使用开发人员工具获取这些按钮的ID对吗?

I had one similar requirement where in some rows i had to show edit button and in some rows i had to hide them based on data in jqgrid. 我有一个类似的要求,在某些行中我必须显示编辑按钮,而在某些行中我必须根据jqgrid中的数据隐藏它们。

so i got the id of those buttons using developer tools and in loadComlete i checked the value of all the rows and hide the buttons. 因此,我使用开发人员工具获取了这些按钮的ID,并在loadComlete中检查了所有行的值并隐藏了按钮。 i think that can be work out for you also. 我认为也可以为您解决。 and talking about onSelectRow or onDblClickRow check the value of isPosted, if its true, you should return false from your function else go with normal editing with something like this 并讨论onSelectRow或onDblClickRow检查isPosted的值,如果为true,则应从函数中返回false,否则进行常规编辑,例如:

jQuery("#grid_id").editRow( id, properties ); jQuery(“#grid_id”)。editRow(id,properties);

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

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