Forum


11:01

05/10/2009

Hi!, JqGrid is amazing, really.
Here's my problem.
I need to have a grid that may be multiselect or uniselect grid dinamically set up when the page is loading (it might be multiselect by a variable set by the user in a previous page)
I'm doing this.
jQuery(document).ready(function() {
jQuery(NOMBRE_GRID).jqGrid({
url: '/BuscadorEmpleado/BuscarEmpleado',
datatype: 'json',
mtype: "POST",
height: 'auto',
multiselect: true,
autowidth: true,
//width: 'auto',
loadui: "enable",
toolbar: [false, "top"],
colNames: ['Id', 'Cedula', 'Nombre', 'Primer Apellido', 'Segundo Apellido'],
colModel: [
{ name: 'id_empleado', index: 'id_empleado', width: 100, align: 'left' },
{ name: 'cedula', index: 'cedula', width: 100, align: 'left' },
{ name: 'nombre', index: 'nombre', width: 100, align: 'left' },
{ name: 'primer_apellido', index: 'primer_apellido', width: 100, align: 'left' },
{ name: 'segundo_apellido', index: 'segundo_apellido', width: 100, align: 'left' }
],
rowNum: tamanoPagina,
rowList: [5, 10, 15, 20],
pager: jQuery(NOMBRE_AREA_PAGINACION),
sortname: 'nombre',
sortorder: "asc",
viewrecords: true,
imgpath: '/scripts/themes/basic/images',
pager: jQuery(NOMBRE_AREA_PAGINACION),
caption: ''
});
jQuery(NOMBRE_GRID).hideCol('id_empleado');
});
jQuery(document).ready(function() {
var multiselect = jQuery("#EmpleadosMultiSeleccion").val();
if (multiselect == UNISELECCION) {
jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb');
}
});
Now when uniseleccion value = false there's no problem, but when uniseleccion is true... the combo box is hidden, but all the information is moved one cell to the left
Now i did another test I set UNISELECCION = false, then there's a multiselect grid loaded fine, then i dinamically with a button do this:
jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb');
And the grid is fine, the the information is not moved one cell to the left. So i'm thinking the problem is when i set the grid without multiselect in jQuery(document).ready(function()).
My question is, what might be wrong, or if it's a jqgrid bug.
06:26

Moderators
30/10/2007

Hello,
Nothing wrong, but you can do this only in 3.5 version:
See this here
http://www.trirand.com/blog/?p.....mment-3231
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.
15:25

30/07/2009

You cant change the multiselect option after creating the grid (well, you could, but you would have to update lots of other internal grid state).
But note that setting multiboxonly results in uni-select behavior except when clicking on the checkbox.
So if you set that, and hide the checkboxes, you should get what you want:
Its also possible to set an onBeforeSelect handler, which effectively gives you complete control over how clicking on rows affects the selection (I dont think you need to do this - but if you ever need more control than the standard options give you, thats the way to do it).
Mark
17:10

05/10/2009

Thank you mark I thought same too about the multibox only and i tested. It seems to work fine until i tried to retrieve the information of the row selected: no row was selected 😛
Well i'm giving up, jeje, thank you all guys, really.
But i really think it's a jqgrid bug, i don't understand why the information is moved one cell to the left.
Thank you again!
PS. This is the code when the information is moved to the left:.
jQuery(document).ready(function() {
jQuery(NOMBRE_GRID).jqGrid({
url: '/BuscadorEmpleado/BuscarEmpleado',
datatype: 'json',
mtype: "POST",
height: 'auto',
multiselect: true,
autowidth: true,
//width: 'auto',
loadui: "enable",
toolbar: [false, "top"],
colNames: ['Id', 'Cedula', 'Nombre', 'Primer Apellido', 'Segundo Apellido'],
colModel: [
{ name: 'id_empleado', index: 'id_empleado', width: 100, align: 'left' },
{ name: 'cedula', index: 'cedula', width: 100, align: 'left' },
{ name: 'nombre', index: 'nombre', width: 100, align: 'left' },
{ name: 'primer_apellido', index: 'primer_apellido', width: 100, align: 'left' },
{ name: 'segundo_apellido', index: 'segundo_apellido', width: 100, align: 'left' }
],
rowNum: tamanoPagina,
rowList: [5, 10, 15, 20],
pager: jQuery(NOMBRE_AREA_PAGINACION),
sortname: 'nombre',
sortorder: "asc",
viewrecords: true,
imgpath: '/scripts/themes/basic/images',
pager: jQuery(NOMBRE_AREA_PAGINACION),
caption: ''
});
var multiselect = jQuery("#EmpleadosMultiSeleccion").val();
if (multiselect == UNISELECCION) {
jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb');
}
jQuery(NOMBRE_GRID).hideCol('id_empleado');
});
Again if multiselect = false, everythings works fine 😀
See ya!
04:04

Moderators
30/10/2007

Hello,
I think you do not read carefully what Mark write.
1. You should set in grid configuration multiselect true and do not change this parameter anymore.
2. You should operate on muliboxonly parameter as of the code above.
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.
13:48

05/10/2009

Tony thank for your reply, i really appreciate you guys on trying to help me.
I did read what mark said, multiboxonly seems to be the right path to give the effect but when I click a row it don't seems to be selected (it's kind of obvious because you need to click the check-box in order to select the row), so when i try to retrieve the selected row, there won't be any selected row. I tried this before got here in the forum.
What I really want to know is why the information is moved one cell to the left? Like in the picture in the first post. Why is this happening when i do jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb') in jQuery(document).ready ?
I don't know if i need to clarify again. I wrote down an event when a button is clicked on the page and i set this instruction
jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb')
and is perfectly working.
Code:
function Acciones(accion) {
switch (accion.id) {
case “linkAceptar”:
case “btnAceptar”:
jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb');
}
}
Picture:
Why is this happening, why on the jQuery(document).ready move the information one cell to the left, and why on a javascript event is working fine?
For me i think it's a bug and it seems like an index in some of the jqgrid code is missing on the way when calling jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb'); on jQuery(document).ready.
Thank you again
PS. Sorry if i'm being kind of annoying or if i don't express my self well. (Greetings from Costa Rica)
15:49

30/07/2009

I did read what mark said, multiboxonly seems to be the right path to give the effect but when I click a row it don't seems to be selected (it's kind of obvious because you need to click the check-box in order to select the row), so when i try to retrieve the selected row, there won't be any selected row. I tried this before got here in the forum.
It may seem obvious - but its not correct... with multiboxonly set to true, you have to click on the check box to get multiselect behavior; but clicking elsewhere on the row gives you uniselect behavior (I've just tested this - it works perfectly).
What I really want to know is why the information is moved one cell to the left? Like in the picture in the first post. Why is this happening when i do jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb') in jQuery(document).ready ?
Because changing the multiselect option after creating the grid is not supported.
I don't know if i need to clarify again. I wrote down an event when a button is clicked on the page and i set this instruction
jQuery(NOMBRE_GRID).setGridParam({ multiselect: false }).hideCol('cb')
and is perfectly working.
No, it isnt. Try refreshing the grid to see that.
Why does it /appear/ to work when you use a button, and not when you use $(document).ready? Well, its because in the latter case, the data comes back from the server /after/ you change the multiselect flag - and any time the grid fetches data from the server when the multiselect flag has been changed, things are going to go wrong. But as I said above, if you cause the data to be refreshed it will fail in both cases...
But here's a question - since you create your grid in a $(document).ready handler, and you change the setting in a $(document).ready handler, why not just create it with the correct setting anyway?
Mark
Most Users Ever Online: 715
Currently Online:
57 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