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
Doubling column header text
22/09/2014
23:13
Avatar
eugene.ostroukhov
New Member
Members
Forum Posts: 1
Member Since:
22/09/2014
sp_UserOfflineSmall Offline

Hello everyone!

I'm trying to use jqGrid with dynamic column list, which generated on a server side.

It's aspnet mvc app, and I will start with js-code (got this one at stackoverflow):

$(document).ready(function() {

$("#find").button({ disabled: false }).click(function() {
jQuery.ajaxSettings.traditional = true;

var compId = $("#Competitions").val();
var roundId = $("#Rounds").val();

$("#ProgressBar").progressbar({ value: false }).show();

var _url = '@Url.Action("GetDataForGrid", "Results")' + '?competitionId=' + compId + '&roundId=' + roundId;

$.ajax(
{
type: "POST",
url: _url,
data: "",
dataType: "json",
success: function (result) {
$("#ProgressBar").hide();

var colD = result.colData;
var colN = result.colNames;
var colM = result.colModel;

jQuery("#Results").jqGrid({
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
cell: "cell"
},
url: _url,
datatype: 'jsonstring',
mtype: 'POST',
datastr: colD,
colNames: colN,
colModel: colM,
pager: jQuery('#pager'),
rowNum: 100,
rowList: [100, 1000],
viewrecords: true,
shrinkToFit: false,
autowidth: true,
});

// TWO FIRST COLUMNS ARE FROZEN (frozen:true)
jQuery("#Results").jqGrid('setFrozenColumns');
},
error: function (x, e) {
alert(x.readyState + " " + x.status + " " + e.msg);
}
});
setTimeout(function() {
$("#Results").jqGrid('setGridParam', { datatype: 'json' });
}, 50);

});

 

Everything is ok with filling my grid, server logic, styles and so on.

Now I'm opening my page (/Results/Index) and clicking #find button to get results.

I can see (screenshots next):

http://gyazo.com/c3c3aa818393b7952bfe18ed50a3ee78

very good, I'm happy.

But second click on #find button shows me next (attention on 1st and 2nd column headers):

http://gyazo.com/25becfd4edd12d3925e4b3a96d716ac7

Two column header texts are doubled.

Third click:

http://gyazo.com/e77d15601f988bb2c6bc11f74ceebd76

You can see here scrolling bar in 2nd column header. So I've got tripling header's text.

And so on.

Html source of page shows identicaly generated code, for each instance of header's <table> tag.

And there's no doublicates for 3rd, 4th and following columns (which are not frozen(!) )

 

jqGrid  4.6.0

jQuery v2.1.1 or 1.10.2 

 

Any ideas what I'm doing wrong?

Many thanks!

Eugene.

 

p.s.: here's json sample, returned by server:

http://gyazo.com/631aaca971dab7f1f884103720dd9dbf

its quite big data for copy-pasting here. if you will need it i will post it as text.

03/10/2014
11:46
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

You can see the data in colNames when you get them to the server and before to put them in the jqGrid.

I thing you should every time the button is clicked to remove the grid, create it again and apply the setting.

 

Regards

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:
15 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