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
LVL 2
sshivannaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971MultitechnicianCommented:
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
 
sshivannaAuthor Commented:
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 );
    });
leakim971MultitechnicianCommented:
I see you already set the url, dou you have a live link (on the web) to check the page ?
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

sshivannaAuthor Commented:
unfortunately no.
What I want to know is, do I need to send parameters using the editurl?
Is so, how do i send it?
leakim971MultitechnicianCommented:
>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
sshivannaAuthor Commented:
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
leakim971MultitechnicianCommented:
"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
sshivannaAuthor Commented:
can you please give me an example of how the server side script would work. It will be great if it is in coldfusion.
leakim971MultitechnicianCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leakim971MultitechnicianCommented:
Hi sshivanna,

Do you need more help?

Kind Regards
sshivannaAuthor Commented:
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
leakim971MultitechnicianCommented:
Could you try a dedicated "edit pagel" ?
If your page is not so huge could you post it in code snipet ?
sshivannaAuthor Commented:
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.
leakim971MultitechnicianCommented:
You're very welcome! Thanks for your explanation and for the points!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.