JQGrid:客户端的内联编辑

时间:2016-09-02 13:16:30

标签: jquery struts2 jqgrid struts2-jquery inline-editing

我只想在客户端使用我的JQGrid(版本4.6.0)。所以,我决定使用内联编辑,所以我把editurl ='clientArray'。

问题是具有editable =“true”属性的行是不可编辑的,为什么?

我的代码:

<@sjg.grid id="gridtable"
    dataType="json"
    loadonce="true"
    href="${remoteurl}"
    pager="true"
    gridModel="myList"
    navigator="true"
    navigatorAdd="false"
    navigatorEdit="false"
    navigatorDelete="false"
    navigatorView="false"
    navigatorRefresh="false"
    navigatorSearch="false"
    rowNum="50"
    rownumbers="true"
    rowList="50,100,200,500,1000,1500,2000"
    viewrecords="true"
    autowidth="true"
    shrinkToFit="true"
    filter="true"
    filterOptions="{searchOnEnter:false}"
    forceFit="true"
    editurl="clientArray"
    onFocusTopics="onSelectRow"
    >

    <@sjg.gridColumn name="col1" index="col1" title="Col1" sortable="true" editable="true" edittype="text" search="true" sorttype="text" width="50" searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc'],clearSearch: false}"/>

// Sélection de ligne
$.subscribe('onSelectRow', function(id) {
    if(id && id!==lastsel){
        jQuery('#gridtable').jqGrid('restoreRow',lastsel);
        lastsel=id;
    }
    jQuery('#gridtable').jqGrid('editRow',id,true);
});

生成的JS:

jQuery(document).ready(function () { 
...
var options_gridtable = {};
...
options_gridtable.datatype = "json";
...
options_gridtable.url = "myURL";
options_gridtable.editurl = "clientArray";
options_gridtable.height = 'auto';
options_gridtable.pager = "gridtable_pager";
options_gridtable.pgbuttons = true;
options_gridtable.pginput = true;
options_gridtable.rowNum = 50;
options_gridtable.rowList = [50,100,200,500,1000,1500,2000];
options_gridtable.viewrecords = true;
options_gridtable.autowidth = true;
options_gridtable.navigator = true;
options_gridtable.navigatoradd = false;
options_gridtable.navigatordel = false;
options_gridtable.navigatoredit = false;
options_gridtable.navigatorrefresh = false;
options_gridtable.navigatorsearch = false;
options_gridtable.navigatorview = false;
options_gridtable.navinline = true;
options_gridtable.loadonce = true;
options_gridtable.filter = true;
options_gridtable.filteroptions = {searchOnEnter:false};
options_gridtable.shrinkToFit = true;
options_gridtable.autoencode = true;
options_gridtable.rownumbers = true;
options_gridtable.colNames = options_gridtable_colnames;
options_gridtable.colModel = options_gridtable_colmodels;
options_gridtable.jsonReader = {};
options_gridtable.jsonReader.root = "myList";
options_gridtable.jsonReader.repeatitems = false;
options_gridtable.jqueryaction = "grid";
options_gridtable.id = "gridtable";
options_gridtable.onfocustopics = "onSelectRow";

jQuery.struts2_jquery_grid.bind(jQuery('#gridtable'),options_gridtable);
 });

 var lastsel;

// Sélection de ligne
$.subscribe('onSelectRow', function(id) {
    if(id && id!==lastsel){
        jQuery('#gridtable').jqGrid('restoreRow',lastsel);             
        lastsel=id;
    }
    jQuery('#gridtable').jqGrid('editRow',id,true);
});

1 个答案:

答案 0 :(得分:0)

sjg:grid的{​​{1}}必须设置为true。