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
Re-Initialize Grid
04/01/2013
18:13
Avatar
KamelJabber
Member
Members
Forum Posts: 4
Member Since:
04/01/2013
sp_UserOfflineSmall Offline
I am trying to reuse the same grid on click of a menu.  So when the user clicks on the menu item I want to 
reload the grid with a new set of parameters. Everything about the grid stays the same, just the parameters 
have changed.  The parameters that are changing is in 'postData'.  I tried so many variations of methods to 
accomplish this but I just can't seem to get it to work.  I tried 'setGridParam' then a .trigger('reloadGrid').  
That didn't work.  The below 'GridUnload" raises an error the second time the user clicks on the menu item. 
 I tried performing a 'clearGridData', that didn't work either.  How can I get the grid to reload with new 
parameters?
Thanks!
                    try {
                        $incidentGrid.jqGrid('GridUnload');
                    }
                    catch (e) {
                        alert(e.message);
                    }

                    $incidentGrid.jqGrid({
                        postData: { 'CSID': CSID, 'FolderId': folderId },
                        ajaxGridOptions: { cache: false },
                        datatype: function (pdata) {
                            var s = (pdata.page - 1) * pdata.rows;
                            var e = pdata.rows;
                                try {
                                    $incidentGrid.block({ message: BusyMsg });

                                    PageMethods.ReadIncidents(pdata.CSID, '', pdata.FolderId, s, e, function (data, context, methodName) {
                                        var dataObj = {};
                                        try {
                                            dataObj = eval('(' + data + ')');
                                        }
                                        catch (e) {
                                            $.writeMessage('Could not parse table data.' + e.message);
                                            return;
                                        }

                                        try {
                                            if (context && context.addJSONData)
                                                context.addJSONData(dataObj);
                                        }
                                        catch (e) {
                                            $.writeMessage(e.message);
                                        }
                                        finally {
                                            $(context).unblock();
                                        }
                                    },
                                    function (error, context, methodName) {
                                        $.writeMessage(error.get_message());
                                        $(context).unblock();
                                    }, this);
                                }
                                catch (e) {
                                    $.writeMessage(e.message);
                                    $incidentGrid.unblock();
                                }
                        },
                        colNames: ['Id', 'Description', 'Date Created', 'Date Modifed', 'Created By', 'CSID', 'wId'],
                        colModel: [
                            { name: 'id', index: 'id', sortable: false, width: 50 },
                            { name: 'desc', index: 'desc', sortable: false },
                            { name: 'dCreated', index: 'dCreated', sortable: false },
                            { name: 'dModified', index: 'dModified', sortable: false },
                            { name: 'cBy', index: 'cBy', sortable: false },
                            { name: 'CSID', index: 'CSID', sortable: false, hidden: true },
                            { name: 'wId', index: 'wId', sortable: false, hidden: true }
                        ],
                        jsonReader: {
                            root: 'data',
                            page: 'page',
                            total: 'total',
                            records: 'records',
                            cell: 'row',
                            id: 'id'
                        },
                        gridview: true,
                        pager: '#tblJqGridPager',
                        viewrecords: true,
                        sortable: false,
                        viewsortcols: [false, 'vertical', false],
                        ExpandColClick: false,
                        shrinkToFit: true,
                        autowidth: true,
                        height: 230,
                        rowNum: 10,
                        onSelectRow: function (id, status, e) {
                            var data = $incidentGrid.jqGrid('getRowData', id);
                            var childWindow = null;
                            var eid = data.id;

                            $.each(landingJS.windows, function (i, v) {
                                if (v.EID + "" == eid) {
                                    childWindow = v;
                                    return false;
                                }
                            });

                            if (childWindow) {
                                landingJS.focus(childWindow.id);
                                return;
                            }

                            var c = landingJS.launchWindow(data.wId, data.CSID, eid, data.desc, [{ 'key': 'IncidentId', 'value': eid }, { 'key': 'CSID', 'value': data.CSID}], false);
                        },
                        gridComplete: function () {
                            var rows = $('#tblJqGrid .ui-row-ltr');

                            if (rows && rows.length > 0)
                                $.each(rows, function (k, v) {
                                    var $v = $(v);
                                    if (!$v)
                                        return true; //skip

                                    var id = $.ToInt($v.attr('id'), 0);

                                    if (id > 0) {
                                        if (!$v.data('draggable')) $v.draggable();

                                        $v.draggable('option', {
                                            cursor: 'pointer',
                                            appendTo: 'body',
                                            cursorAt: {
                                                top: 0,
                                                left: 0
                                            },
                                            start: function (e, ui) {
                                                $(this).parent().fadeTo('fast', 0.5);
                                            },
                                            stop: function (e, ui) {
                                                $(this).parent().fadeTo(0, 1);
                                            },
                                            helper: function (e) {
                                                var e = $(this);
                                                var id = e.prop('id');
                                                var dragView = $('dragging');

                                                $('TD', dragView).each(function () {
                                                    $(this).attr('nowrap', 'nowrap');
                                                });

                                                return dragView;
                                            }
                                        });
                                    }
                                });


                            this.setGridWidth(layout.state.center.innerWidth).trigger('resize');
                        }
                    });
04/01/2013
21:20
Avatar
KamelJabber
Member
Members
Forum Posts: 4
Member Since:
04/01/2013
sp_UserOfflineSmall Offline

It was TOUGH but the answer was so simple!

After the unload I needed to reset my local variable:

                    try {
                        $incidentGrid.jqGrid('GridUnload');
                        $incidentGrid = $('#tblJqGrid');
                    }
                    catch (e) {
                        alert(e.message);
                    }
Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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