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
Inline edit causing error in json.parse
30/06/2010
13:07
Avatar
garethahealy
Member
Members
Forum Posts: 5
Member Since:
24/05/2010
sp_UserOfflineSmall Offline

I am using json2 (http://www.JSON.org/json2.js - 2010-03-20) and jQuery 1.4.2.

I have inline editing allowed. When a user edits the grid and submits an empty field, i do server side validation, and if its invalid (I.e: an empty field), I return a json object with a message. This works fine in IE 8 and Firefox 3.6.6 on jqGird 3.6.4.

I upgraded from 3.6.4, to 3.6.5 and found that this DOES NOT work in IE now, but does in Firefox, instead json2.js throws an error on: "return this.valueOf();" complaining that "Object doesn't support this property or method".

I then upgraded to 3.7, and the problem still occurs. The only change on my side of the code is upgrading the grid, jquery/json2 and all other code has not changed in 2 months.

Has the way in which an AJAX call parses the data returned changed?

Cheers.

30/06/2010
15:57
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Please post all the code related to the grid, or maybe you will need to read this:

http://www.trirand.com/jqgridw.....4_to_3.6.5

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

30/06/2010
18:15
Avatar
garethahealy
Member
Members
Forum Posts: 5
Member Since:
24/05/2010
sp_UserOfflineSmall Offline

This JS file loads first and sets up the default settings, as well as having some shared methods. (I use the grid on several pages)

Intellident.JqGridShared = function() {
    return {

        selectedRow: function(id, lastSelected) {
            var grid = $('#grid');

            if (id && id !== lastSelected) {
                grid.jqGrid('restoreRow', lastSelected);
                grid.jqGrid('editRow', id, true, '', Intellident.JqGridShared.selectedRowSaved, '', '', '', Intellident.JqGridShared.selectedRowError, '');
            }

            return id;
        },

        disablePaging: function(xhr) {
            Intellident.JqGridShared.disablePagingForPager(xhr, 'pager');
        },

        disablePagingForPager: function(xhr, pager) {
            if (xhr) {
                if (xhr.Total <= 1) {
                    $('#' + pager + '_center :input').attr('disabled', true);
                }
            }
        },

        selectedRowSaved: function(xhr) {
            if (xhr) {
                if (xhr.responseText && xhr.status == '200') {
                    var result = JSON.parse(xhr.responseText);
                    if (result) {
                        Intellident.Common.displayErrorMessage(result.Error);

                        return result.IsSaved;
                    }
                }
            }

            return false;
        },

        selectedRowError: function(rowId, xhr) {
            window.location.replace('Exception/HandleException');
        },

        loadJqGridPager: function(grid) {
            grid.jqGrid('navGrid', '#pager', {
                edit: false,
                add: false,
                del: false,
                search: false,
                refresh: true
            });
        },

        setupJqGridDefaults: function() {
            $.jgrid.defaults = $.extend($.jgrid.defaults, {
                autowidth: true,
                datatype: 'json',
                gridview: true,
                height: 'auto',
                imgpath: '/Content/Images/JQuery-UI',
                jsonReader: {
                    id: 'Id',
                    page: 'Page',
                    total: 'Total',
                    records: 'Records',
                    repeatitems: false,
                    root: 'Rows',
                    userdata: 'UserData'
                },
                loadui: 'block',
                mtype: 'GET',
                multiboxonly: true,
                multiselect: true,
                pager: '#pager',
                rowNum: 10,
                rowList: [10, 20, 30, 40, 50, 100],
                sortorder: 'asc',
                viewrecords: true
            });
        }
    };
} ();

$(document).ready(function() {
    Intellident.JqGridShared.setupJqGridDefaults();
});

I then load the below JS, for this page.

Intellident.EditUser = function() {
    return {

        setupJqGrid: function() {
            $.jgrid.defaults = $.extend($.jgrid.defaults, {
                colNames: [_languageJson.All_ApplyCancel, _languageJson.EditUser_Actions, '', _languageJson.EditUser_Username, _languageJson.EditUser_Fullname, _languageJson.EditUser_Email, _languageJson.EditUser_CreationTimestamp, '', '', _languageJson.EditUser_LastLogin, ''],
                colModel: [
                            { name: 'ApplyCancel', index: 'ApplyCancel', sortable: false, width: 38 },
                            { name: 'Actions', index: 'Actions', sortable: false, width: 56 },
                            { name: 'Id', index: 'Id', editable: false, hidden: true, key: true },
                            { name: 'Username', index: 'Username', editable: true, hidden: false, sort: true },
                            { name: 'Fullname', index: 'Fullname', editable: true, hidden: false, sort: true },
                            { name: 'Email', index: 'Email', editable: true, hidden: false, sort: true },
                            { name: 'CreationTimestamp', index: 'CreationTimestamp', editable: false, hidden: false, sort: true },
                            { name: 'IsActive', index: 'IsActive', editable: false, hidden: true, sort: true },
                            { name: 'IsLocked', index: 'IsLocked', editable: false, hidden: true, sort: true },
                            { name: 'LastLogin', index: 'LastLogin', editable: false, hidden: false, sort: true },
                            { name: 'IsSystemType', index: 'IsSystemType', editable: false, hidden: true, sort: true }
                          ],
                editurl: 'EditUser/EditUser',
                sortname: 'Username',
                url: 'EditUser/GetUsers',
                loadError: function(xhr, status, error) {
                    window.location.replace('Exception/HandleException');
                }
            });
        },

        loadJqGrid: function(grid) {
            var lastsel;
            grid.jqGrid({
                onSelectRow: function(id) {
                    var isSystemType = grid.jqGrid('getCell', id, 'IsSystemType');
                    if (isSystemType == 'false') {
                        lastsel = Intellident.JqGridShared.selectedRow(id, lastsel);
                    }
                },
                loadComplete: function(xhr) {
                    Intellident.JqGridShared.disablePaging(xhr);
                }
            });
        },

        loadJqGridPager: function(grid) {
            grid.jqGrid('navGrid', '#pager', {
                edit: false,
                add: false,
                del: false,
                search: false,
                refresh: true
            }).jqGrid('navButtonAdd', '#pager', { id: 'AddItem', caption: '', buttonicon: 'ui-icon-add', onClickButton: Intellident.JqGridShared.showAddItem, position: 'last', title: _languageJson.EditUser_Add, cursor: 'pointer'
            }).jqGrid('navButtonAdd', '#pager', { id: 'DeleteItem', caption: '', buttonicon: 'ui-icon-del', onClickButton: Intellident.EditUser.deleteItems, position: 'last', title: _languageJson.EditUser_Delete, cursor: 'pointer' });
        }
    };
} ();

$(document).ready(function() {
    Intellident.EditUser.setupJqGrid();
    Intellident.EditUser.loadJqGrid($('#grid'));
    Intellident.EditUser.loadJqGridPager($('#grid'));
});

From the link you pointed me to, i could not see anything that i should be changing.

* _languageJson is a global object i access to have custom text values from the server.

Hope this helps.

30/06/2010
18:21
Avatar
garethahealy
Member
Members
Forum Posts: 5
Member Since:
24/05/2010
sp_UserOfflineSmall Offline

I also use the 'no_legacy' option.

06/07/2010
11:30
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Where appear exatly the error?

If you use the old json lib does the error appear?

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
23 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