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
jqGrid dynamically build
19/07/2013
09:48
Avatar
weinhorn
New Member
Members
Forum Posts: 2
Member Since:
19/07/2013
sp_UserOfflineSmall Offline

Hello!
I've registered here because I have a little problem.
I want to build my jqGrid dynamically. All values ​​come from the SQL DB. The table is set up correctly, just does not the paging, sorting and filtering. When I enter my colmodel directly in the script, then everything works. So the string looks in the database for each field:

ID  colModel (column in DB, text)
—————————
1   name: 'ID', index: 'ID', width: 60, sorttype: 'int'
2   name: 'Title', index: 'Title', width: 90, align: 'right', search: true, searchoptions: { sopt: ['cn']}

And here is a part of the script on the client side:

        function loadGrid() {
            $.ajax({
                type: "POST",
                url: siteName + "/_vti_bin/IntranetWCFcustomService/myWCFservice.svc/getSettingForJqGrid?serverName=" + serverName + "&dbName=" + dbName + "&tableName=" + $("#tableName").val() + "&viewsID=" + $("#viewsID").val() + "&formID=" + $("#formID").val(),
                dataType: "json",
                success: function (response) {
                    var gridName = response[0]["Titel"];
                    var cnames = response[0]["ColNames"];
                    var cmodel = response[0]["ColModels"];
                    var rowNum = response[0]["RowNum"];

                    jQuery("#list_inventory").jqGrid({
                        url: siteName + "/_vti_bin/IntranetWCFcustomService/myWCFservice.svc/getSqlData?serverName=" + serverName + "&dbName=" + dbName + "&tableName=" + $("#tableName").val() + "&viewsID=" + $("#viewsID").val() + "&formID=" + $("#formID").val(),
                        datatype: "json",
                        height: $("#<%=_ClientID.Text %>_heightValue").val(),
                        autowidth: true,
                        rowNum: rowNum,
                        rowList: [10, 20, 30],
                        colNames: cnames,
                        colModel: cmodel,
                        pager: "#plist_inventory",
                        viewrecords: true,
                        sortname: 'ID',
                        sortorder: 'ASC',
                        onSelectRow: function (ID) { getDetails(ID); },
                        caption: gridName,
                        toolbar: [true, "top"]
                    }).navGrid('#plist_inventory', { edit: false, add: false, del: false, search: false });
                    jQuery("#list_inventory").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false });
                },
                error: function (response) {
                    alert(response.responseText);
                }
            });
            return false;
        }

Where can the problem be then?  If I would have my ColModel string in the wrong format, I would get an error message that COLNAMES and CoModel have different lengths. I do not get this message.
I'm sorry for my English!

Sincerely yours
wolfgang

23/07/2013
11:02
Avatar
weinhorn
New Member
Members
Forum Posts: 2
Member Since:
19/07/2013
sp_UserOfflineSmall Offline

Ok, I have now solved itself. The Colmodel was present as a string, it must be prepared again:

var colmodel = "[";
                    for (x = 0; x < cmodel.length; x++) {
                        colmodel += cmodel[x] + ",";
                    };
                    colmodel = colmodel.slice(0, -1);
                    colmodel += "]";

And then eval(colmodel);

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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