Welcome Guest Search | Active Topics | Sign In | Register

Grid addItem Options
Guest
Posted: Friday, January 22, 2010 11:43:26 AM
Rank: Guest
Groups: Guest

Joined: 5/27/2007
Posts: -34
Hi,

I need to add a list of values to the grid.

When I use the following code nothing appears within the grid. Please could you post a simple example of adding items to the grid using javascript. Thanks.

function addNewItem(itemtoadd)
{
var grid = eo_GetObject("Grid1");
var item = grid.addItem();
item.setValue = "set";
item.ensureVisible();
alert(cnt);
}
eo_support
Posted: Friday, January 22, 2010 12:01:50 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Please make sure your Grid's RunningMode property is set to "Client". You can't add item with JavaScript when the Grid is in Server or Callback running mode.

All the following code is wrong:

item.setValue = "set";

It should be something like this:

item.getCell(0).setValue("anything");

setValue is a method. So you must call it with (). Also there is no value per item. Values are associated to each cell.

A full working sample is available here:

http://demo.essentialobjects.com/Default.aspx?path=Grid\_i1\_i8

You can take a look of/copy the source code from there.

Thanks!
Guest
Posted: Saturday, January 23, 2010 6:07:33 AM
Rank: Guest
Groups: Guest

Joined: 5/27/2007
Posts: -34
Thank you for your prompt reply it was as per usual very helpful and has fixed my problem.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.