jqGrid:在内联编辑中选择行的文本

时间:2013-03-13 18:52:42

标签: jqgrid selection inline-editing

我有一个网格,我正在使用PHP和JSON。我正在使用ondblClickRow进行内联编辑。我需要的是:当我在一个字段中双击时,我希望选择该字段的内容。我很遗憾地询问这个问题,但是我没有找到这个...当我在Google上搜索它时,我只是找到了选择行和这个问题的例子。

4 个答案:

答案 0 :(得分:2)

我建议您查看this answeranother one。可能会从您使用的Web浏览器的最后一个答案中修改代码,这样就可以解决您的问题。

答案 1 :(得分:0)

如果您希望在启用内联编辑模式后单个单元格聚焦,请尝试以下操作:

ondblClickRow: function (rowId, rowIndex, columnIndex) {
  var grid = $('#mygrid');
  grid.editRow(rowId, true, function() {
    var colModel = grid.getGridParam('colMode');
    var colName = colModel[colIndex].name;
    var input = $('#' + rowId + '_' + colName);
    input.get(0).focus();
  });
}
}

在这里找到代码: http://www.trirand.com/blog/?page_id=393/help/setting-focus-on-a-cell-after-entering-edit-mode/

答案 2 :(得分:0)

如果点击它时网格中有特定的列应选择其内容,则在colmodel中将此代码添加到每列:

{
    name: 'TEXT_BOX',
    index: 'TEXT_BOX',
    label: 'Notes',
    width: 100,
    align: 'left',
    sortable: false,
    hidden: false, 
    dataEvents: [ { type: 'click', data: { i: 7 }, fn: function(e) { e.target.select(); } }] 
}

dataEvents会在您点击时选择输入字段中的文字。

答案 3 :(得分:0)

// Text will get Selected of cell when inline editing 
    $('#gridTableObj').jqGrid({
        ....
        ..
        afterEditCell : function(rowid, cellname, value, iRow, iCol){
            $('#'+rowid+'_'+cellname).select(); // with this the edited cell value will be selected.            
        }
        ...
        ..

    });
相关问题