Forum
03:44
Moderators
30/10/2007
Hello,
Use the newly option scrollrows : true and then apply a setSelection to the new added row - jqGrid is flexible 🙂
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.
07:52
19/12/2008
Hi,
I use scrollrows:true and setSelected, but the grid does not scroll dynamically (the row is correctly selected). My code is :
jQuery(document).ready(function(){
var initialLoad = true;
jQuery("#listSociete").jqGrid({
scrollrows : true,
url:'getValues.php?type=contentSociete',
datatype: "json",
colNames:['Nom','Secteur d\\'Activité', 'Progiciel', 'Commercial'],
colModel:[
{name:'Nom',index:'Nom', align:"left", sortable:true, search: true},
{name:'NomSecteur',index:'NomSecteur', sortable:true, search: true},
{name:'NomOutil',index:'NomOutil', sortable:true, search: true}
,{name:'NomCommercial',index:'NomCommercial', sortable:true, search: true}
],
hidegrid: false,
hiddengrid: false,
loadui:'block',
loadtext:"Chargement...",
pager: jQuery('#pagerSociete'),
pgbuttons:false,
pginput:false,
viewrecords:true,
sortname: 'Nom',
sortorder: "asc",
caption: "Sociétes",
forceFit: true,
loadonce: false,
width: 1000,
onSelectRow: function(rowid) {
// Memorisation de la societe selectionnee
memoriseVariable('societeSelected', rowid); // Puts id in a COOKIE
},
loadComplete: function() {
// Selection de la ste memorisee
if (initialLoad && recupereVariable('societeSelected')) // If first lload and cookie is set
jQuery("#listSociete").setSelection(recupereVariable('societeSelected'), true);
initialLoad = false;
}
});
02:04
Moderators
30/10/2007
Hello,
It is not setSelected, but setSelection - check the right syntax in the docs.
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.
01:17
Moderators
30/10/2007
Hello glemarie,
You use this in loadComplete - this will not work - since not all the data is alredy into the grid. Try to use this after the grid is loaded
and you will see that this will work. Not sure what you try to do, but maybe gridComplete is your event.
A simple test:
$("#mybutton").click(function(){
// here your code with set selection
})
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.
17:55
17/09/2009
Hi tony,
jqGrid 3.5.3, 'scrollrows' parameter not scroll to row selected. The row is selected but not scroll in view.
I tried in 'gridcomplete' event and a button click event.
The grid options are simple:
jQuery("#list").jqGrid({
url: jq_url,
datatype: "xml",
colNames:[etc, etc],
colModel:[{etc},{etc}],
rowNum:25,
rowList:[25,50,75],
gridview: true,
scrollrows: true,
height: jq_Height,
hidegrid: false,
loadui:"block",
caption: jq_caption,
loadBeforeSend: function(xhr){
jq_rowsBackground = rowsBackground();
},
gridComplete: function() {
if (jq_rowsBackground !== undefined) {
if (jq_rowsBackground.records > 0) {
$.each(jq_rowsBackground.rows, function(row){
jQuery('tr#'+ this,'#list').css({background:'#d3f7cf'});
});
}
}
if (jq_last_visit != 0){
jQuery("#list").setSelection(jq_last_visit);
}
}
});
Code Comments: (All 'jq*' are Javascript variables. No Pager if datasource is ODBC, Pager active if datasource is MySql.)
Best regards,
Ignacio
03:31
Moderators
30/10/2007
Hello,
Not sure if this is a case, but there was a bug (which is corrected in GitHub) when the parameter is number - i.e. in your case jq_last_visit is number. Try this:
jQuery(”#list”).setSelection(jq_last_visit+"");
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.
11:57
17/09/2009
Indeed, the jq_last_visit variable contains numeric data ('2755 ').
However, I changed the code to make it a string data type ( 'r2755'), the behavior is the same, the row is selected and not scroll in view.
I tested from GitHub grid.base same thing.
After many tests, I found the solution: the problem occurs when there is no previously selected row.
I changed the code to:
gridComplete: function() {
jQuery(”#list”).setSelection(jq_first_row_id("#list"));
if (jq_rowsBackground !== undefined) {
if (jq_rowsBackground.records > 0) {
$.each(jq_rowsBackground.rows, function(row){
jQuery('tr#'+ this,'#list').css({background:'#d3f7cf'});
});
}
}
if (jq_last_visit != 0){
jQuery(”#list”).setSelection(jq_last_visit);
}
}
function jq_first_row_id(gridID){
var grid = jQuery(gridID);
rowsID = grid.getDataIDs();
return rowsID[0];
}
In the button click event:
jQuery(”#list”).setSelection(jq_first_row_id("#list"));
if (jq_last_visit != 0){
jQuery(”#list”).setSelection(jq_last_visit);
}
Now is scroll in view. (Clearly, there is always checked rows in grid.). Only a 'mini' problem: only middle row in view, because the row height is not multiple of the height of the grid table.
Many thanks for your assistance.
Best regards,
Ignacio
Most Users Ever Online: 715
Currently Online:
73 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