Forum


06:47

15/09/2011

Hi....someone, please!!
I am trying to freeze my first grid column but with no luck. I have version 4.3, and I have frozen:true in my dynamic column model. What I cent seem to be able to do is call the method correctly. WHERE and HOW in my code below do I place the call to setFrozenColumns???
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "GET",
url: "xxxxxxxxxxx",
dataType: "json",
success: function(result){
var colD = result.pfcTills,
colM = result.colModelList;
$("#dataGrid").jqGrid({
datatype: 'local',
data: colD.gridData,
gridview: true,
colModel :colM,
height: "100%",
width: 1000,
shrinkToFit: false,
caption:"MONTHLY SUMMARY",
sortable: true,
rowNum: 100,
loadComplete: function(data){ }
}
});
}
});
});
</script>
Does anyone know the answer please?
Thanks.
10:41

Moderators
30/10/2007

Hello,
I preffer you to click on the documentation menu
Kind 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.
@slykiwi you cab refer this example to freeze first column
jQuery("#UsersGrid").jqGrid({
url: 'jqGridHandler.ashx',
datatype: 'json',
height: 250,
colNames: ['UserID', 'UserName', 'FirstName', 'MiddleName', 'LastName', 'EmailID'],
colModel: [
{ name: 'UserID', index: 'UserID', width: 100, sortable: true, frozen: true },
{ name: 'UserName', width: 100, sortable: true },
{ name: 'FirstName', width: 100, sortable: true },
{ name: 'MiddleName', width: 100, sortable: true },
{ name: 'LastName', width: 100, sortable: true },
{ name: 'EmailID', width: 150, sortable: true }
],
rowNum: 100,
rowList: [200, 400, 600],
pager: '#UsersGridPager',
sortname: 'UserID',
viewrecords: true,
shrinkToFit: false,
width: 300,
sortorder: 'asc',
caption: 'JSON Example'
});
jQuery("#UsersGrid").jqGrid('navGrid', '#UsersGridPager');
jQuery("#UsersGrid").jqGrid('setFrozenColumns');
00:06

15/09/2011

Tony,
I had already looked at the documentation and know what I am meant to do i.e:
jQuery("#dataGrid").jqGrid('setFrozenColumns');
&
frozen:true
but I can't seem to get it to work, HENCE I posted on here. It is where in my code that the line calling the method setFrozenColumns should be that is my question. I have tried it in multiple places but cant get it to work, so need to know where it SHOULD go. When I know this, if it still does not work, then I can look at other possibilities.
"mafirstlove"........ thanks for your help. Would you expect that jQuery("#dataGrid").jqGrid('setFrozenColumns'); would go at the very end of my code after the last set of brackets like in yours? The way my grid is constructed it different from yours?
Thanks.
00:12

10/08/2009

Probably you will find the answers on your question in the answer and in this one.
Best regards
Oleg
00:46

15/09/2011

Hey Oleg,
Thanks for the prompt reply. I have read the links you sent me, and assume that my datatype of local is the issue. I also should say that unlike the demo, not even my header is fixed (I should also say that I do not change any of the heights or CSS).
Any chance you coul dguide me through this a bit more please? I inserted the following bwtween the brackets of my loadComplete:
var $this = $(this), newCapture = "", filters, rules, rule, op, i, iOp,
postData = $this.jqGrid("getGridParam", "postData"),
isFiltering = $this.jqGrid("getGridParam", "search");
if (isFiltering === true && typeof postData.filters !== "undefined") {
filters = $.parseJSON(postData.filters);
newCapture = "Filter: [";
rules = filters.rules;
for (i = 0; i < rules.length; i++) {
rule = rules[i];
op = rule.op; // the code name of the operation
iOp = $.inArray(op, arOps);
if (iOp >= 0 && typeof $.jgrid.search.odata[iOp] !== "undefined") {
op = $.jgrid.search.odata[iOp];
}
newCapture += rule.field + " " + op + " '" + rule.data + "'";
if (i + 1 !== rules.length) {
newCapture += ", ";
}
}
newCapture += "]";
}
$this.jqGrid("setCaption", newCapture);
fixPositionsOfFrozenDivs.call(this);
Where exactly in my code should the following go:
fixPositionsOfFrozenDivs = function () { if (typeof this.grid.fbDiv !== "undefined") { $(this.grid.fbDiv).css($(this.grid.bDiv).position()); } if (typeof this.grid.fhDiv !== "undefined") { $(this.grid.fhDiv).css($(this.grid.hDiv).position()); } }, arOps = ["eq", "ne", "lt", "le", "gt", "ge", "bw", "bn", "in", "ni", "ew", "en", "cn", "nc"];
I also have this now after the last brackets of my code at the beginning of this post:
$grid = $('#dataGrid');
$grid.jqGrid('setFrozenColumns');
$grid[0].p._complete.call($grid[0]);
Cheers Oleg.
01:00

10/08/2009

Hello,
many parts of my old code which you posted will be probably not important for you. You should just define the fixPositionsOfFrozenDivs function with the code var fixPositionsOfFrozenDivs = function () { ...}; somewhere before the usage and include call of fixPositionsOfFrozenDivs.call(this); inside of loadComplete function. It's also important to call p._complete after the call of setFrozenColumns.
The most easy way is the copy my demo and modify it by removing some parts to have the simpllest, but working demo. Then you can use the same ideas in your code.
Best regards
Oleg
01:54

15/09/2011

Thanks again Oleg,
This will be my last post before I give up on this thing!
I keep getting the error $grid[0] is undefined.
Here is my final mix of your demol and my code. The grid and data loads no problem:
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/css/ui.jqgrid.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/js/jquery.jqGrid.src.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$grid = $("#dataGrid"),
fixPositionsOfFrozenDivs = function () {
if (typeof this.grid.fbDiv !== "undefined") {
$(this.grid.fbDiv).css($(this.grid.bDiv).position());
}
if (typeof this.grid.fhDiv !== "undefined") {
$(this.grid.fhDiv).css($(this.grid.hDiv).position());
}
};
$.ajax({
type: "GET",
url: "cfc/contacts.cfc?method=pfcTillsMonth&storeID=<cfoutput>#form.storeID#</cfoutput>&year=<cfoutput>#form.year#</cfoutput>",
dataType: "json",
success: function(result){
var colD = result.pfcTills,
colM = result.colModelList;
$grid.jqGrid({
datatype: 'local',
data: colD.gridData,
gridview: true,
colModel :colM,
height: "100%",
width: 1000,
shrinkToFit: false,
caption:"PFC TILLS MONTHLY SUMMARY",
sortable: true,
rowNum: 100,
loadComplete: function(data){
fixPositionsOfFrozenDivs.call(this);
}
});
}
});
$grid.jqGrid('setFrozenColumns');
$grid[0].p._complete.call($grid[0]);
fixPositionsOfFrozenDivs.call($grid[0]);
});
</script>
<table id="dataGrid"></table>
You can see from the following dump that frozen is set in the colModel:
{"colModelList":[{"name":"PRDID","sortable":false,"frozen":true,"label":"Item Description","width":200.0,"editable":false,"index":"PRDID","hidden":false},{"name":"Jan","sortable":false,"width":100.0,"editable":false,"label":"January","align":"right"},{"name":"Feb","sortable":false,"width":100.0,"editable":false,"label":"February","align":"right"},{"name":"Mar","sortable":false,"width":100.0,"editable":false,"label":"March","align":"right"},.......
Any last suggestions please mate??
Thanks.
09:27

Moderators
30/10/2007

Hello,
There is enought time to give up.
You should call these lines of code
$grid.jqGrid('setFrozenColumns');
within the success ajax function and not outside it.
$.ajax({
....
success : function (...)
{
...
$grid.jqGrid({
...
});
$grid.jqGrid('setFrozenColumns');
} // END SUCCESS
}); // END AJAX
....
If you call it so the grid is not yet constructed, since of the ajax call.
Please read carfully what ajax does.
Another simple way to fix this is to set ajax option
async: false.
without to change your code.
Baest 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.
10:05

10/08/2009

Hello,
I want to add one more probelm in your JSON data additionally to the problem described by Tony. The JSON data which you posted one sees that you set the property frozen:true only for hidden column. So no frozen columns will be created and so $grid[0].p._complete will be null. If you want to make your code working without errors in the situation you should use
In any way if you want to test setFrozenColumns method you should define at least one non-hidden column having frozen:true.
Best regards
Oleg
00:24

15/09/2011

Hey Tony / Oleg....
Ok, Im not yet ready to give up on this. I tried your suggestion Tony and moved the $grid.jqGrid('setFrozenColumns'); within the success ajax function. It still did not work:
<script type="text/javascript">
$(document).ready(function () {
$grid = $("#dataGrid"),
fixPositionsOfFrozenDivs = function () {
if (typeof this.grid.fbDiv !== "undefined") {
$(this.grid.fbDiv).css($(this.grid.bDiv).position());
}
if (typeof this.grid.fhDiv !== "undefined") {
$(this.grid.fhDiv).css($(this.grid.hDiv).position());
}
};
$.ajax({
type: "GET",
url: "xxxxxx",
dataType: "json",
success: function(result){
var colD = result.pfcTills,
colM = result.colModelList;
$grid.jqGrid({
datatype: 'local',
data: colD.gridData,
gridview: true,
colModel :colM,
height: "100%",
width: 1000,
shrinkToFit: false,
caption:"PFC TILLS MONTHLY SUMMARY",
sortable: true,
rowNum: 100,
loadComplete: function(){
fixPositionsOfFrozenDivs.call(this);
}
});
$grid.jqGrid('setFrozenColumns');
$grid[0].p._complete.call($grid[0]);
fixPositionsOfFrozenDivs.call($grid[0]);
}// END SUCCESS
});// END AJAX
});
</script>
I also (without changing my code) set async: false. This made no difference also.
Oleg, the first entry in my column model list from above is:
{"name":"PRDID","sortable":false,"frozen":true,"label":"Item Description","width":200.0,"editable":false,"index":"PRDID","hidden":false}
Hidden is set to false unless I am missing something? There are no hidden columns. I have since removed any reference to hidden columns anyway.
Thanks again gents!
01:08

10/08/2009

Hello,
the code which you posted gives not so many information because you don't posted the JSON data which can be used to reproduce your problem. The demo use datatype: 'json' and it do work.
If you post the full code which can be used to reproduce your problem one could find the reason of your problem.
Best regards
Oleg
01:14

15/09/2011

Hi Oleg,
Here is a complete dump of the Coldfusion serialized JSON data after calling my cfc:
{"colModelList":[{"name":"PRDID","sortable":false,"frozen":true,"label":"Item Description","width":200.0,"editable":false,"index":"PRDID"},{"name":"Jan","sortable":false,"width":100.0,"editable":false,"label":"January","align":"right"},{"name":"Feb","sortable":false,"width":100.0,"editable":false,"label":"February","align":"right"},{"name":"Mar","sortable":false,"width":100.0,"editable":false,"label":"March","align":"right"},{"name":"Apr","sortable":false,"width":100.0,"editable":false,"label":"April","align":"right"},{"name":"May","sortable":false,"width":100.0,"editable":false,"label":"May","align":"right"},{"name":"Jun","sortable":false,"width":100.0,"editable":false,"label":"June","align":"right"},{"name":"Jul","sortable":false,"width":100.0,"editable":false,"label":"July","align":"right"},{"name":"Aug","sortable":false,"width":100.0,"editable":false,"label":"August","align":"right"},{"name":"Sep","sortable":false,"width":100.0,"editable":false,"label":"September","align":"right"},{"name":"Oct","sortable":false,"width":100.0,"editable":false,"label":"October","align":"right"},{"name":"Nov","sortable":false,"width":100.0,"editable":false,"label":"November","align":"right"},{"name":"Dec","sortable":false,"width":100.0,"editable":false,"label":"December","align":"right"},{"name":"Total","sortable":false,"width":130.0,"editable":false,"label":"Total","align":"right"}],"pfcTills":{"gridData":[{"Mar":"$2,519.95","Sep":"$13,638.00","Aug":"$12,887.75","Nov":"$20,306.00","Feb":"$9,944.95","Total":"","May":"$26,688.35","Jul":"$10,060.45","Jun":"$12,228.85","Jan":"$10,558.40","Oct":"$23,500.95","PRDID":"Opening Cash on Hand","Dec":"$19,159.55","Apr":"$7,769.65"},{"Mar":"","Sep":"","Aug":"","Nov":"","Feb":"","Total":"","May":"","Jul":"","Jun":"","Jan":"","Oct":"","PRDID":"Cash In","Dec":"","Apr":""},{"Mar":"$60,570.00","Sep":"$55,000.00","Aug":"$55,000.00","Nov":"$55,000.00","Feb":"$47,302.00","Total":"$677,002.00","May":"$45,000.00","Jul":"$55,000.00","Jun":"$55,000.00","Jan":"$54,130.00","Oct":"$55,000.00","PRDID":"From Lenders A\/C","Dec":"$65,000.00","Apr":"$75,000.00"},{"Mar":"$80.00","Sep":"$100.50","Aug":"$40.00","Nov":"$0.00","Feb":"$80.00","Total":"$1,439.35","May":"$200.30","Jul":"$417.50","Jun":"$280.00","Jan":"$144.55","Oct":"$16.50","PRDID":"Mon-e & Advantage Default fees","Dec":"$0.00","Apr":"$80.00"},{"Mar":"$231.00","Sep":"$445.50","Aug":"$2,261.03","Nov":"$520.00","Feb":"$676.50","Total":"$7,500.03","May":"$412.50","Jul":"$445.50","Jun":"$462.00","Jan":"$643.50","Oct":"$313.50","PRDID":"Brokered Cash Advance Default Fees","Dec":"$462.00","Apr":"$627.00"},{"Mar":"$27,015.65","Sep":"$22,334.13","Aug":"$19,728.84","Nov":"$20,970.07","Feb":"$24,267.73","Total":"$263,295.48","May":"$22,236.16","Jul":"$21,670.49","Jun":"$18,700.82","Jan":"$18,556.16","Oct":"$21,006.10","PRDID":"Brokered Cash Advance OTC Payments","Dec":"$17,693.43","Apr":"$29,115.90"},{"Mar":"$0.00","Sep":"$0.00","Aug":"$0.00","Nov":"$0.00","Feb":"$0.00","Total":"$26.00","May":"$0.00","Jul":"$0.00","Jun":"$26.00","Jan":"$0.00","Oct":"$0.00","PRDID":"WU Received from Customers","Dec":"$0.00","Apr":"$0.00"},{"Mar":"$85.00","Sep":"$112.35","Aug":"$267.70","Nov":"$69.40","Feb":"$42.00","Total":"$1,574.81","May":"$20.00","Jul":"$497.61","Jun":"$106.10","Jan":"$60.00","Oct":"$46.30","PRDID":"Cheque Cashing Income","Dec":"$180.35","Apr":"$88.00"},{"Mar":"$294.00","Sep":"$1,011.15","Aug":"$2,426.01","Nov":"$103.00","Feb":"$378.00","Total":"$12,218.98","May":"$0.00","Jul":"$5,508.53","Jun":"$1,154.59","Jan":"$360.00","Oct":"$416.70","PRDID":"Other","Dec":"$0.00","Apr":"$567.00"},{"Mar":"$88,348.40","Sep":"$79,454.96","Aug":"$79,723.58","Nov":"$78,328.38","Feb":"$72,746.23","Total":"$966,351.33","May":"$67,868.96","Jul":"$83,539.63","Jun":"$75,729.51","Jan":"$73,955.11","Oct":"$77,223.23","PRDID":"Total Cash In","Dec":"$83,955.44","Apr":"$105,477.90"},{"Mar":"","Sep":"","Aug":"","Nov":"","Feb":"","Total":"","May":"","Jul":"","Jun":"","Jan":"","Oct":"","PRDID":"Cash Out","Dec":"","Apr":""},{"Mar":"$81,261.00","Sep":"$66,852.25","Aug":"$75,828.53","Nov":"$78,028.42","Feb":"$79,063.00","Total":"$930,218.47","May":"$81,167.11","Jul":"$74,355.64","Jun":"$75,865.85","Jan":"$70,934.23","Oct":"$79,460.96","PRDID":"Brokered Cash Advance Out","Dec":"$82,549.71","Apr":"$84,851.77"},{"Mar":"$0.00","Sep":"$0.00","Aug":"$0.00","Nov":"$0.00","Feb":"$0.00","Total":"$0.00","May":"$0.00","Jul":"$0.00","Jun":"$0.00","Jan":"$0.00","Oct":"$0.00","PRDID":"Western Union Money Out","Dec":"$0.00","Apr":"$0.00"},{"Mar":"$1,484.04","Sep":"$2,231.19","Aug":"$2,731.94","Nov":"$1,425.25","Feb":"$672.01","Total":"$24,737.44","May":"$789.84","Jul":"$5,822.26","Jun":"$1,686.01","Jan":"$3,141.92","Oct":"$913.00","PRDID":"Banked to Store A\/C","Dec":"$2,459.73","Apr":"$1,380.25"},{"Mar":"$253.80","Sep":"$468.40","Aug":"$412.22","Nov":"$22.00","Feb":"$390.91","Total":"$3,546.03","May":"$371.64","Jul":"$527.32","Jun":"$346.52","Jan":"$393.58","Oct":"$11.00","PRDID":"Other Expenses","Dec":"$22.00","Apr":"$326.64"},{"Mar":"$82,998.84","Sep":"$69,551.84","Aug":"$78,972.69","Nov":"$79,475.67","Feb":"$80,125.92","Total":"$958,501.94","May":"$82,328.59","Jul":"$80,705.22","Jun":"$77,898.38","Jan":"$74,469.73","Oct":"$80,384.96","PRDID":"Total Cash Out","Dec":"$85,031.44","Apr":"$86,558.66"},{"Mar":"$2,519.95","Sep":"$13,638.00","Aug":"$12,887.75","Nov":"$20,306.00","Feb":"$9,944.95","Total":"","May":"$26,688.35","Jul":"$10,060.45","Jun":"$12,228.85","Jan":"$10,558.40","Oct":"$23,500.95","PRDID":"Opening Cash on Hand","Dec":"$19,159.55","Apr":"$7,769.65"},{"Mar":"$88,348.40","Sep":"$79,454.96","Aug":"$79,723.58","Nov":"$78,328.38","Feb":"$72,746.23","Total":"","May":"$67,868.96","Jul":"$83,539.63","Jun":"$75,729.51","Jan":"$73,955.11","Oct":"$77,223.23","PRDID":"Gross Total In","Dec":"$83,955.44","Apr":"$105,477.90"},{"Mar":"$82,998.84","Sep":"$69,551.84","Aug":"$78,972.69","Nov":"$79,475.67","Feb":"$80,125.92","Total":"","May":"$82,328.59","Jul":"$80,705.22","Jun":"$77,898.38","Jan":"$74,469.73","Oct":"$80,384.96","PRDID":"Out Total","Dec":"$85,031.44","Apr":"$86,558.66"},{"Mar":"$7,869.51","Sep":"$23,541.12","Aug":"$13,638.64","Nov":"$19,158.71","Feb":"$2,565.26","Total":"","May":"$12,228.72","Jul":"$12,894.86","Jun":"$10,059.98","Jan":"$10,043.78","Oct":"$20,339.22","PRDID":"Amount That Should Be In Till","Dec":"$18,083.55","Apr":"$26,688.89"},{"Mar":"$7,769.65","Sep":"$23,500.95","Aug":"$13,638.00","Nov":"$19,159.55","Feb":"$2,519.95","Total":"","May":"$12,228.85","Jul":"$12,887.75","Jun":"$10,060.45","Jan":"$9,944.95","Oct":"$20,306.00","PRDID":"Acutal Amount In Till","Dec":"$18,086.90","Apr":"$26,688.35"},{"Mar":"($99.86)","Sep":"($40.17)","Aug":"($0.64)","Nov":"$0.84","Feb":"($45.31)","Total":"($320.89)","May":"$0.13","Jul":"($7.11)","Jun":"$0.47","Jan":"($98.83)","Oct":"($33.22)","PRDID":"Cashier's Discrepancy","Dec":"$3.35","Apr":"($0.54)"}]}}
The data loads into the grid without any problem. I hope this helps you to help me.
Thanks.
01:30

10/08/2009

Everything is easy if one can reproduce the problem.
You should remove sortable: true option from the grid to be able to use frozen columns: see the modified demo.
Look at the documentation about the limitations in the current implementation or look the line of jqGrid code.
Best regards
Oleg
14:35

17/01/2012

Frozen cols is great improvement but...We need use celledit together
There is an alternative way but I don't know how to implement...
Allocate 2 grids NO FROZEN cos, left grid contains 'fixed' cols, right grid contains all editable cols but none frozen cols.
The only problem is capture scroll event from two grids and sync both toprow
But I don't know how to do that.
Heavyvice
Most Users Ever Online: 715
Currently Online:
45 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66