0

I've implemented a jqGrid, but when I try to use the built-in form edit feature, an empty form pops up.

For every column i have set editable:true except for the table's primary key, an auto-incremented id. What am I doing wrong? Do I need to have a valid editurl, rather than clientArray? Below is the jqGrid implementation:

$.ajax({
    type: "GET",
    url: colUrl,
    datatype: "json",
    success: function(result){
        result = jQuery.parseJSON( result )
        var colN = result.colNames;
        var colM = result.colModelList;
        $("#jqTable").jqGrid({
            url:dataUrl,
            datatype: 'xml',
            mtype: 'GET',
            colNames:colN,
            colModel:colM,
            shrinkToFit: false,
            caption: db + "." + table,
            pager: '#jqPager',
            rowNum:10,
            rowList:[10,20,30],
            sortname: 'dbid',
            editurl: 'clientArray',
            sortorder: 'asc',
            viewrecords: true,
            width: 1000,
            height: 400
          });
        $("#jqTable").jqGrid('navGrid', '#jqPager',
            {edit:true, add:false, del:false, search:true, view:false}, //options
            {}, // edit options
            {}, // add options
            {}, // del options
            {multipleSearch:true,
             sopt : ['eq',//equals
                 'ne',//not equals
                 'lt',//less than
                 'le',//less than or equal
                 'gt',//greater than
                 'ge',//greater than or equal
                 'bw',//begins with
                 'bn',//does not begin with
                 'in',//in
                 'ni',//not in
                 'ew',//ends with
                 'en',//does not end with
                 'cn',//contains
                 'nc']//does not contain
            }, // search options
            {} //view options
        ); 
    },
    error: function(x,e){
        alert(x.readyState + " " + x.status + " " + e.msg);
    }
});

and here is sample colModel and ColName string:

"colModelList": [{"name":"dbid","index":"dbid","editable":"false"},{"name":"description","index":"description","editable":"true"},{"name":"file_name","index":"file_name","editable":"true"}],"colNames": ["dbid","description","file_name"]
Andrea
  • 1,057
  • 1
  • 20
  • 49

1 Answers1

4

I suppose that the reason is because you use "editable": "true" or "editable": "false" instead of "editable": true or "editable": false.

Moreover you try to use form editing for the local data editing. The current jqGrid implementation support local data editing only for cell editing and inline editing. If you do need to use form editing to edit local data you can find my demo in the answer. The code will be longer, but it is do possible to implement this.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Changed "editable":"true" to "editable":true and the form becomes populated. Awesome! – Andrea May 16 '11 at 14:54
  • 1
    @Andrea: On [www.json.org](http://www.json.org/) you can find that the boolean data type should be encoded without double quotes. – Oleg May 16 '11 at 14:59
  • Sometimes it's the simplest things... I was rewriting the control flow of my application and had set a default to all editable items as `false` and couldn't figure out what was happening. Found my bug and fixed it, thanks :) – blong Aug 24 '11 at 14:52
  • Oh, I spent 4 hours on this issue :( Thank Oleg! – ymakux Nov 18 '12 at 17:58