0

I am working in the concrete5 cms, I trying to implement jqgrid in my web application. I did jqgrid view in the form but i dont know howw to edit, delete and all function in the jqgrid.

the problem was if I select the row in the jqgrid and delete, it was deleted in the front view but how to delete in my database and how to pass the sID value to my controller.

enter image description here

var myData = <?php echo json_encode($sl) ?>;

    $("#statGrid").jqGrid({
        caption: 'Status List',
        datatype:'local',
        data: myData,
        mtype:'POST',
        colNames:['sID','Status Name','Type','Description'],
        colModel:[ 
            {name:'status_id',editable:true }, 
            {name:'status_name',editable:true },
            {name:'status_type',editable:true },
            {name:'status_description', editable:true, edittype: 'textarea' } ],
        width: "777",
        height: "auto",
        pager:'#statPager',
        rowNum:5, 
        rowList:[5,10,20,30],
        rownumbers: true,
        viewrecords: true,
        recreateForm:true,
        gridView: true,
        autoencode: true,
        editurl: "editStatus",
        loadui:'enable'

    }).navGrid("#statPager",{add:false, edit:true, view:false, del:true, search:false, refresh:false });

How to pass exact sID through parameter in the grid. please guide me about the jqgrid. to solve this problem. if any mistake in my question sorry, i will develop my question skillthanks.

Kumar Shanmugam
  • 597
  • 1
  • 11
  • 40

1 Answers1

1

I suppose that 'status_id' column contains unique ids which you want to see on the server side in the URL "editStatus". In the case you should add key: true to the definition of 'status_id' column. In the case the value from the column will be used as the rowid (the value of id attribute of <tr> elements of the grid which represent the rows of data). The data, which will be posted to the server during deleting of the row, are described here.

Small remarks to your code. You should replace gridView: true to gridview: true, change width: "777" to width: 777, remove recreateForm:true (bacause it's the option of form editing and not the option of jqGrid). If you need set some common values to colModel like editable:true you can remove the properties editable:true from colModel and uses jqGrid option cmTemplate: {editable: true} instead. See the answer for details.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • thanks a lot for the reply and your suggestions @Oleg . still i have problem in the 'editurl'.... In the firebug show the data of id and oper but in my controller not get the value, so what i did wrong – Kumar Shanmugam Feb 13 '14 at 11:21
  • I change gridview, width and remove recreateForm and also added the cmTemplate its working fine thanks once again – Kumar Shanmugam Feb 13 '14 at 11:26
  • 1
    You are welcome! If you see that *correct information* will be sent to the server then you should verify your server code. It should just read the `id` and `oper`. – Oleg Feb 13 '14 at 11:47
  • Hi sorry i have one more question, this following code is not working may i know why? 'navGrid("#statPager",{add:false, edit:true, view:false, del:true, search:false, refresh:false }, {reloadAfterSubmit: true, jqModal: true, closeOnEscape: true, closeAfterEdit: true}, {closeOnEscape: true});' the closeonEscape in the delete not working? – Kumar Shanmugam Feb 13 '14 at 11:58
  • @KumarShanmugam: Thanks! Is the problem is solved now? – Oleg Feb 13 '14 at 11:59