Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Invalid Json when using exporting a Grid with events defined
03/11/2010
11:42
Avatar
john
Member
Members
Forum Posts: 9
Member Since:
24/02/2009
sp_UserOfflineSmall Offline

i have a grid which has actions defined for the onPaging, onSelectRow and gridComplete events

When i use the jqGridExport function to export the grid to the server it seems to work OK, but when i run the JSON that it creates through JSONLint it says the JSON is invalid for these actions.

My jqGridExport command is:

var jsonGrid = jQuery("#tableReport").jqGridExport({exptype: "jsonstring", root: "tableReport"});

$.post("/SOA/Grid.soa", {grid: jsonGrid, report: "today"});

The code for my onSelectRow event is:

        onSelectRow: function(id){
            if(id && id!==lastRow){
                $("#tableReport").saveRow(lastRow, false);
                $("#tableReport").editRow(id,true);
                lastRow=id;
            }
        }

The JSON created is:

       …..
        "beforeSelectRow": null,
        "onSelectRow": function (id) {
            if (id && id !== lastRow) {
                $("#tableReport").saveRow(lastRow,
                false); $("#tableReport").editRow(id,
                true); lastRow = id;
            }
        },
        "onSortCol": null,
       …….

The JSONLint message is: 'syntax error, unexpeted TINVALID at line nnn'

Just a thought, could it be because i am in Belgium? i know that in some applications i need to use semicolons as value delimiters in lists

i have resolved this by making my Server code strip out the event methods. Then in my jqGridImport call i re-add them.

30/05/2011
16:43
Avatar
rui.isidro@gmail.com
New Member
Members
Forum Posts: 1
Member Since:
29/03/2010
sp_UserOfflineSmall Offline

Did you find any other solution? I'm also having problems with this. I have a few events attached to a grid and I whant to export the grid, but I always get errors with JSON because of the deveined event handler functions.

30/05/2011
17:34
Avatar
john
Member
Members
Forum Posts: 9
Member Since:
24/02/2009
sp_UserOfflineSmall Offline

No, i had to work arround it. when i save the grid i have to first edit it in the java service code to remove all events before saving it to the database.

The code i use to do that is as follows

public void saveGrid(String grid, String user, String report) {

System.out.println(">>>GridServiceImpl.saveGrid");

// strip out all grid events (e.g. onSelectRow, onPaging, gridComplete

int i = grid.indexOf("onSelectRow");

int j = grid.indexOf("onSortCol") - 1;

grid = grid.substring(0, i) + "onSelectRow\":null," + grid.substring(j) ;

i = grid.indexOf("onPaging");

j = grid.indexOf("onSelectAll") - 1;

grid = grid.substring(0, i) + "onPaging\":null," + grid.substring(j) ;

i = grid.indexOf("gridComplete");

j = grid.indexOf("loadError") - 1;

grid = grid.substring(0, i) + "gridComplete\":null," + grid.substring(j) ;

System.out.println(grid);

try {

Model.perform("saveGrid", new Object[] {user, report, grid });

} catch (Exception e) {

e.printStackTrace();

}

}

 Then in my javascript i reload the events after the jqGridImport function

jQuery('#tableReport').jqGrid('setGridParam', { 'onPaging':function(btn){

$("#tableReport").appendPostData({refresh:false});

var vSelectedIds;

vSelectedIds = $("#tableReport").getGridParam('selarrrow');

$("#tableReport").appendPostData({ticked:vSelectedIds});

}});

hope that helps.

john 

30/05/2011
17:37
Avatar
john
Member
Members
Forum Posts: 9
Member Since:
24/02/2009
sp_UserOfflineSmall Offline

i should add, i use firebug to show me the layout of the json data being sent to the server. then for each event i note the name of the event and the name of the following event in the JSON and replace it as shown in the java sample.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
179 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information