Link to home
Start Free TrialLog in
Avatar of sshivanna
sshivannaFlag for United States of America

asked on

pass parameters from jqgrid for edit

I am trying to edit a row in the jqgrid. I realize that I need to use the editurl to call the script that would update the record. How do I send the row values as parameters using editurl?

Please help.

Thank you
Sharath
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Could you post you current jqgrid options ?

You should have something like :

$("mygrid").jqgrid(options);

in option you should to set this editurl

options = {"editurl":"myPageDoingTheUpdate.php.asmx.cf",...others options

Additionaly you can set this url directly with : jQuery("#grid_id").jqGrid('editGridRow', rowid, properties );

where properties (check list here : http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing)

properties = { "url":"myPageDoingTheUpdate.php.asmx.cf", ... other properties
 
Avatar of sshivanna

ASKER

This is my coldfusion and jquery script

        $("#name_desc_grid").jqGrid({              
            <cfoutput>
                url: GIT.docroot + "cfcs/grid/surveys.cfc?method=#method#&#idField#=#survey_id#&pagesize=5&returnFormat=plain",
            </cfoutput>
            <cfoutput>
                editurl: GIT.docroot + "cfcs/grid/surveys.cfc?method=#editMethod#&#idField#=#survey_id#",
            </cfoutput>
            datatype: "json",
            colNames:['Code', 'Language', 'Survey Name', 'Survey Description/Purpose', 'Order'],
            colModel:[
                {name:'code', index:'code', hidden:true },
                {name:'lang_name', index:'lang_name', width:60, editable:false },
                {name:'name', index:'name', width:220, editable:true },
                {name:'description', index:'description', width:320, editable:true },
                {name:'display_order', index:'display_order', hidden:true }
            ],
            rowNum: 5, rowList: [5],
            pager: "#name_desc_grid_pager",
            height: "100%",
            viewrecords: true,
            sortname: 'display_order',
            sortorder: 'asc',
            loadComplete: function(data) {
                if (data.records == 0) {
                    $("#name_desc_grid").jqGrid('GridDestroy');
                    $("#name_desc_none").show();
                }
            }
        }).navGrid("#name_desc_grid_pager"
                   , { refresh: true
                   , search: false
                   , edit: true
                   , add: true
                   , del: true
                   , refreshtext: "Reload"}
                   ,{width:600});
        $(window).bind('resize', resizeGrid );
    });
I see you already set the url, dou you have a live link (on the web) to check the page ?
unfortunately no.
What I want to know is, do I need to send parameters using the editurl?
Is so, how do i send it?
>What I want to know is, do I need to send parameters using the editurl?

No, only the url.
On the server side you get the datas of the row to update
If I am not sending the values as parameters through the URL, how am I going to get the data of the row to update?

Thanks
"jqgrid" send the data automatically with an ajax call to the urledit function specified.

on the server you get the data as usual (querying parameters)

code
lang_name
...
display_order

and the oper to know the operation :
"add" to insert a new row from the datas
"edit" to update the row from the data

assuming one of the parameter is your id/primary key you can do the update with an sql query
can you please give me an example of how the server side script would work. It will be great if it is in coldfusion.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi sshivanna,

Do you need more help?

Kind Regards
Yes leakim971

I am still working on this and unable to solve a problem. I am getting a coldfusion error saying

Element CODE is undefined in ARGUMENTS.

Code is one of the fields when I am selecting the data. But, I am not able to understand why this error is coming up.

Thank you
Sharath
Could you try a dedicated "edit pagel" ?
If your page is not so huge could you post it in code snipet ?
Thanks leakim971, I was able to figure out the problem. There were 2 issues with what I was doing.

I needed the value of a column 'code'. I was not passing that value. I had to define it as

{name:'code', index:'code', hidden:true, editable:true }

So this wouldn't show on the screen but would still get passed to the edit page.

The 2nd problem was, there was an 'id' parameter being passed. I mistook it to be the id in the database. Actually this is a jqgrid custom generated id. I had to explicitly pass it again.

These 2 helped me fix the issue.

Thanks a lot for your help.
You're very welcome! Thanks for your explanation and for the points!