I've started to implement the editing capability of jqGrid in APEX. After looking at the documentation briefly, I struggled to understand how I could change the POST parameters when rows were saved, as by default I was getting this:

And what I actually needed, was them in the form of x01, x02 etc. So after a bit of searching, looking at the actual code and then back at the wiki, everything was pointing at a non-existent function called "serializeRowData". I then realized that when we create our jqGrid we can pass this function as one of the config parameters just like we do for "onSelectRow".

For simplicity and the fact that APEX onDemnad processes only cater for 10 variables I decided to pass the data back in an actual JSON object, well a string representation of it to be precise, as I'll post process it server side with PLJSON. All I needed to do was convert my postdata object into a string and convert it back to a JSON object and I got a little help from json2.js for that. Here's the solution:


jQuery("#tableid").jqGrid({
....
serializeRowData: function(postdata){
return { x01: JSON.stringify(postdata) };
}
....
});


Which results in the following:




The next step was to add a new member function to the JSON type in PLJSON to extract the column names to use in the query, i.e. as they are the keys. There's no existing functionality that provides this, but it was simple as the following:


member function get_keys return json_list as
keys json_list;
indx pls_integer;
begin
keys := json_list();
indx := json_data.first;
loop
exit when indx is null;
keys.add_elem(json_data(indx).member_name);
indx := json_data.next(indx);
end loop;
return keys;
end;
edit post

Comments

5 Response to 'jqGrid - Custom post parameters when editing'

  1. Anonymous
    http://theapexfreelancer.blogspot.com/2010/01/jqgrid-custom-post-parameters-when.html?showComment=1263893447147#c3325868243414688364'> January 19, 2010 at 1:30 AM

    Really interesting project, I've been looking for a good Ajax-based grid to replace the built-in tabular forms in Apex. Looking forward to see the results of your work!

     

  2. Bhavin Adhvaryu
    http://theapexfreelancer.blogspot.com/2010/01/jqgrid-custom-post-parameters-when.html?showComment=1267439444571#c376542931533523583'> March 1, 2010 at 2:30 AM

    Hi Matt,

    I'm working to integrating my applications with jQuery. I would be very pleased if you can provide your code. At we are not allowed to integrate other than jQuery so we are thinking to use jQuery Grid functionality for our report with good pagination functionality.

    Can you please let me know, how can I integrate jQuery Grid within Apex.

    Your help would be apprecaited.

    Kind Regards,
    Bhavin
    London, UK

     

  3. mnolan
    http://theapexfreelancer.blogspot.com/2010/01/jqgrid-custom-post-parameters-when.html?showComment=1267570981232#c3350476590232576841'> March 2, 2010 at 3:03 PM

    Hi Bhavin

    I'll be publishing the integration in about 6-8 weeks time, I've just got a lot on my plate at the moment so I just don't have the time to get it all packaged and documented. It's always the case with unpaid work, it always takes a back seat. However if you/your company is willing to make some financial contribution, I'm sure I can squeeze it in :)

    Cheers
    Matt

     

  4. Anonymous
    http://theapexfreelancer.blogspot.com/2010/01/jqgrid-custom-post-parameters-when.html?showComment=1271689289564#c4869567535255777947'> April 19, 2010 at 8:01 AM

    Hi Mnolan,

    is there something new in your jqGrid integation? Do you still work on integration?

    Kind Regards,
    David

     

  5. mnolan
    http://theapexfreelancer.blogspot.com/2010/01/jqgrid-custom-post-parameters-when.html?showComment=1271692863726#c3074043832756939030'> April 19, 2010 at 9:01 AM

    Hi David

    I haven't had much time lately to dedicate to the integration, I progressed far enough for 1 company to release it into production, it supports some features which I have not blogged about:

    - inline adding
    - validation and meiomask plugin integration
    - ability to set colModel options for the invidual report columns using the comments section
    - auto grid resizing on parent container resize

    I will be looking to make it available for download in the near future on a new company website which I'm releasing soon (also built using APEX). I'll then aim to add new features based on feedback from the community.

    In the interim there is a different integration solution available for jqGrid and APEX that Morten Braten has made available: http://ora-00001.blogspot.com/2010/03/jqgrid-integration-kit-for-plsql-and.html

    Cheers
    Matt

     

Post a Comment