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
elem[0] is undefined in call to setRowData()
10/03/2009
13:57
Avatar
jnavratil
Member
Members
Forum Posts: 23
Member Since:
12/02/2009
sp_UserOfflineSmall Offline

jquery 1.3.1

jqGrid 3.4.1

FireFox 3.0.7

Fedora 10 (64-bit)

I am trying to implement the edit buttons as shown in the "Custom Edit" demo.  My loadComplete() method is...

loadComplete: function(){
   var ids = jQuery(gridName).getDataIDs();
   for(var i=0;i<ids.length;i++) {
      var cl = ids[i];
      alert(cl + ' name:' + gridName);
      be = "<input style='height:22px;width:20px;' type='button' value='E' onclick=jQuery('"+gridName+"').editRow("+cl+"); />";
      se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=jQuery('"+gridName+"').saveRow("+cl+"); />";
      ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=jQuery('"+gridName+"').restoreRow("+cl+"); />";
      alert(be+se+ce);
      jQuery(gridName).setRowData(ids[i],{act:be+se+ce});
      }
},

I have verified the colNames and colModels contain the same number of elements and that the colNames and ColModel.name is 'act'.  The be+se+ce string is....

<input style='height:22px;width:20px;' type='button' value='E' onclick=jQuery('#grid').editRow(1); />
<input style='height:22px;width:20px;' type='button' value='S' onclick=jQuery('#grid').saveRow(1); />
<input style='height:22px;width:20px;' type='button' value='C' onclick=jQuery('#grid').restoreRow(1); />

(I did notice in the demo code there was what seemed to be a spurious '></ids>' at the end of the first input which I removed)

My call is ...

jQuery(gridName).setRowData(ids[i],{act:be+se+ce});

In each case I get then elem[0] is undefined in grid.base.js line 715.

If I change the 'act' to 'xxx', I get no error and obviously no buttons.

What am I missing?

11/03/2009
03:17
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Do you have defined a act coulmn in the 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.

11/03/2009
06:12
Avatar
jnavratil
Member
Members
Forum Posts: 23
Member Since:
12/02/2009
sp_UserOfflineSmall Offline

Tony,

Yes.  The thing I am doing differently from the example is that I have queried the database table I wish to edit for its schema so that I can build a table dynamically.  First I build an array of colNames and colModels, then I use them to define the grid.  Using the javascript debugger, I have verified that colNames[7] is "act" and colModel[7] is {index : "act", name : "act", sortable : false, width : 75} when used in the jqGrid constructor.

I have no reason to suspect any problem as the table is properly populated with the data from the table.

Thanks for any help you may have, and thanks as well for this marvelous plugin.

-- John

11/03/2009
07:13
Avatar
jnavratil
Member
Members
Forum Posts: 23
Member Since:
12/02/2009
sp_UserOfflineSmall Offline

Tony,

I added...

            var cm = $('#grid')[0].p.colModel;

... to my loadComplete() method and verified that cm[7] contained {index : “act”, name : “act”, sortable : false, width : 75}.

-- John

11/03/2009
08:06
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Try to use gridComplete and not loadComplete.

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/03/2009
08:34
Avatar
jnavratil
Member
Members
Forum Posts: 23
Member Since:
12/02/2009
sp_UserOfflineSmall Offline

Tony,

I changed loadComplete() to gridComplete() and observed the same behaviour.

In stepping through the code, I observe this is a problem selecting the object.  The selector is "td:eq(7)", but at the time of the call there are only 7 columns in the grid with the result that an object of length 0 is passed into the formatter.

All column headings are displayed, but it seems the body of the grid has not yet had the column for the buttons added.  In fact, below the "Actions" heading there appears to be nothing (no zebra stripes).  I have attempted to put the buttons on the right of the grid, while the example has them on the left.

Is there something I should do to force this column to be present?

Thanks!

-- John

11/03/2009
08:50
Avatar
jnavratil
Member
Members
Forum Posts: 23
Member Since:
12/02/2009
sp_UserOfflineSmall Offline

Tony,

I added another column to my database query to return a blank 'act' column with the result that I had a grid column defined.  Now I have buttons.  That is, my database query became ...

SELECT invid,invdate,client_id,amount,tax,total,note, '' as act FROM invheader ORDER BY invid asc LIMIT 0 , 10

By adding the " ' ' as act " to the query, the json reader created the extra grid column I needed.

Is there a better way to do this?

Thanks,

-- John

12/03/2009
11:22
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

This is the right way.

Reagrds

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.

12/03/2009
13:09
Avatar
jnavratil
Member
Members
Forum Posts: 23
Member Since:
12/02/2009
sp_UserOfflineSmall Offline

Tony,

After reading this, I went back to the demo code and noticed the empty string as the first element of the array to correspond to the 'act' column.

I suppose I should have gotten the demo working first to build confidence, but I am sometimes too impatient.

Do you think a comment in the demo code explaining that would be valuable?  I'm sure you have enough to do, but it would have helped me.  You could, in fact, change the empty string to "act placeholder" to illustrate the point.  Just a thought!

Thanks,

-- John

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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