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
Mutiselect problem
05/10/2009
11:01
Avatar
sanchitos
Member
Members
Forum Posts: 14
Member Since:
05/10/2009
sp_UserOfflineSmall Offline

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

ErrorImage Enlarger

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/10/2009
06:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

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.

06/10/2009
12:44
Avatar
sanchitos
Member
Members
Forum Posts: 14
Member Since:
05/10/2009
sp_UserOfflineSmall Offline

Updated to JqGrid 3.5 and same thing is happening. Problem is not solved :(, information is moved one cell to the left.

Does anyone have you tried transform a multiselect grid to uniselect grid in loading phase?

Thank you, any comment will be appreciated .

06/10/2009
15:25
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

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:

jQuery(NOMBRE_GRID).setGridParam({ multiboxonly: true }).hideCol('cb');

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

06/10/2009
17:10
Avatar
sanchitos
Member
Members
Forum Posts: 14
Member Since:
05/10/2009
sp_UserOfflineSmall Offline

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!

07/10/2009
04:04
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

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.

07/10/2009
13:48
Avatar
sanchitos
Member
Members
Forum Posts: 14
Member Since:
05/10/2009
sp_UserOfflineSmall Offline

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:

WorkingImage Enlarger

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)

07/10/2009
15:49
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

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

07/10/2009
16:41
Avatar
sanchitos
Member
Members
Forum Posts: 14
Member Since:
05/10/2009
sp_UserOfflineSmall Offline

Mark thank you very much! The thing was that i had version 3.4 on my server, I upgraded to 3.5 and the option

jQuery(NOMBRE_GRID).setGridParam({ multiboxonly: true }).hideCol('cb');

is actually working.

Thank you again 😉

Topic closed!!! jeje

PS. Sorry for all the inconvenient

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information