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
Id from server
17/09/2008
08:27
Avatar
shlang
Member
Members
Forum Posts: 3
Member Since:
17/09/2008
sp_UserOfflineSmall Offline

Hello,

Please explain me how to use id sent from server...

i have

{name:'UserId', key: true, index:'users.UserId', width:30, sorttype:"int"}

in my colmodel. but when editing or deleting server gets parameter id={number of current row}. But i need userId...

17/09/2008
09:26
Avatar
YamilBracho
Member
Members
Forum Posts: 124
Member Since:
08/09/2008
sp_UserOfflineSmall Offline

Hi.
My colModes is as follows:

   colModel :[
              { name: "co_sector", index: "co_sector", width: 20, editable: true, search: false },
              { name: "nb_sector", index: "nb_sector", width: 90, editable: true, editoptions: {size: "60", maxlength: "60"}, editrules:{requerided:true}}
            ],
      
And I hides the "co_sector" (that it is my PK)

jQuery("#list").hideCol(["co_sector"]);   

When I submit the data in a "edit" action I receive the co_sector as part of the QueryString.

For delete operation I just add the "co_sector" data in the beforeSubmit method of the delete options. My code is:

 { height:90, width:300,  reloadAfterSubmit:false,
              beforeSubmit: function() {
                 var sr = jQuery("#list").getGridParam('selrow');
                 var rowData = jQuery("#list").getRowData(sr);
            
                  this.delData = {"co_sector" : rowData['co_sector']};
                  retarr = {"co_sector" : rowData['co_sector']};
                  return retarr;
              }
            }, // del options

HTH

17/09/2008
09:44
Avatar
shlang
Member
Members
Forum Posts: 3
Member Since:
17/09/2008
sp_UserOfflineSmall Offline

I found a bug. In grid.base.js we have

      for (var i=0; i<ts.p.colModel.length;i++) {
            if (ts.p.colModel[i].key===true) {
                ts.p.keyIndex = i;
                break;
            }
            i++;
        }

So because of two increments my key column was skipped. I changed it to

if(ts.p.multiselect) n=1;
else n=0;
        for(i=0;i<this.p.colNames.length;i++){
            if (ts.p.colModel[i+n].key===true) {
                ts.p.keyIndex = i;
                break;
            }
        }

Now it works 🙂

17/09/2008
10:46
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Thank you for this, but sorry this is not a bug.

The for statement is called after constructing the multiselect and subgrid

additinal columns, so this must work - check your code again.

Check your server code again and pay attention on what you return from

server -  Is the name exactly as those from colModel.

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/09/2008
11:07
Avatar
shlang
Member
Members
Forum Posts: 3
Member Since:
17/09/2008
sp_UserOfflineSmall Offline

I return from server xml without any names:

<row ID="3">
<cell>3</cell>
<cell>Alex Bokun</cell>
<cell>+5296418677</cell>
<cell>Gsmart 300</cell>
<cell>34523452345</cell>
<cell>Inactive</cell>
</row>

17/09/2008
11:19
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Did you see the difference ?

<row ID=”3″>

should be

<row id=”3″>

or change the xmlReader to read the ID instead of id

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/09/2008
13:26
Avatar
YamilBracho
Member
Members
Forum Posts: 124
Member Since:
08/09/2008
sp_UserOfflineSmall Offline

I apply those changes to my code but still I received the row num instead the primary key in the id parameter in an "edit" action. I build my json data as :

 rows :[
      {id: "11",cell:["11","ADMISTRACIÓN LEGAL Y FINANZAS"]}
 ]}

And, say, this is the row 3 when i show those data in the grid and when I edit i received the "id" parameter as "3" and not as "11"...

why ?

18/09/2008
09:21
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

How looks your jsonReader like?

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.

18/09/2008
17:13
Avatar
YamilBracho
Member
Members
Forum Posts: 124
Member Since:
08/09/2008
sp_UserOfflineSmall Offline

My jsonReader is:

jsonReader: {
        repeatitems : true,
        id: "0"
            },

19/09/2008
01:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Try with this

jsonReader: {
        repeatitems : true,
        id: "id"
            },

There is a bug when id:"0" (only) since java interpret "0" as false.

I have corrected this.

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.

22/09/2008
10:35
Avatar
YamilBracho
Member
Members
Forum Posts: 124
Member Since:
08/09/2008
sp_UserOfflineSmall Offline

Sorry Tony,

I still receive the row number as id and not the primary key value...

22/09/2008
17:24
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

to be correct you JSON response should look like:

“rows” :[
      {"id": "11","cell":["11","ADMISTRACIÓN LEGAL Y FINANZAS"]}
 ]}

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.

23/09/2008
10:53
Avatar
YamilBracho
Member
Members
Forum Posts: 124
Member Since:
08/09/2008
sp_UserOfflineSmall Offline

I have:

I have:

rows :[
{id: "11",cell:["11","ADMISTRACIÓN LEGAL Y FINANZAS"]},
{id: "4",cell:["4","ASEGURADORA, ARREDADORA FINANCIERA Y OTROS AFINES"]},
{id: "16",cell:["16","CAJA DE AHORRO, COOPERATIVA O AFINES"]},
{id: "10",cell:["10","CENTROS EDUCATIVOS Y AFINES"]},
{id: "2",cell:["2","COMERCIALIZADORA DE PRODUCTOS ELECTRÓDOMESTICOS, COMPUTACIÓN, MAN"]},
{id: "1",cell:["1","EDITORIAL, VENTA DE LIBROS (MAYOR O DETAL) Y AFINES"]},
{id: "14",cell:["14","EMPRESAS DE CONSULTORÍA, DESARROLLO DE SOFTWARE Y AFINES"]},
{id: "17",cell:["17","EMPRESAS DE SERVICIOS EN GENERAL"]},
{id: "15",cell:["15","FUNDACIÓN SIN FINES DE LUCRO"]},
{id: "9",cell:["9","INMOBILIARIAS, ADMINISTRADORAS DE BIENES RAÍCES Y AFINES"]}
]}

And in my grid i have

            colNames:['Codigo','Nombre'],
            colModel :[
              { name: "co_sector", index: "co_sector", key: true, width: 20, editable: false, search: false, hidden:true },
              { name: "nb_sector", index: "nb_sector", width: 90, editable: true, editoptions: {size: "60", maxlength: "60"}, editrules:{requerided:true}}
            ],

            jsonReader: {
        repeatitems : true,
        id: "co_sector"
            },

But I don't receive "co_sector" when edit or delete a row...

24/09/2008
04:05
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I think you mixed colModel with the real JSON data in the jsonReader.

Try with the default options of jsonReader - i.e. do not set in your grid

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.

24/09/2008
08:49
Avatar
YamilBracho
Member
Members
Forum Posts: 124
Member Since:
08/09/2008
sp_UserOfflineSmall Offline

Thanks Tony but it does not work.

Anyway I pass the id using editData in the beforeSubmit event and works ok...

28/05/2009
10:21
Avatar
ww9rivers
Member
Members
Forum Posts: 11
Member Since:
20/05/2009
sp_UserOfflineSmall Offline

Cool! I got it to work following this thread with edit and delete functions with the right "id" I need.

Thanks!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
74 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