|
Rank: Member Groups: Member
Joined: 5/3/2010 Posts: 11
|
Hi there,
After reading the Client API and looking at the code for ItemCommandServerEvent Demo, i was trying to use this on my own code. I was wondering, your demo is using it to select a whole row and having the FullRowMode set to true; can i use this RaiseItemCommandEvent while having my FullRowMode set to false so that i can select individual cells? If not, then is there an equivalent one to use when the FullRowMode is set to false? Thanks!
Laura
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You should be able to use RaisesItemCommandEvent anytime. The method is NOT used to select a row. It has nothing to with row selection --- even though you may call it when a row is selected, but that's totally up to you. The method triggers server side ItemCommand event and that's pretty much all it does. You call it whenever you feel this particular function can be of any use to you.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/3/2010 Posts: 11
|
Hi, so following your demo, i wrote the following in my own code, but when i try to run it, it gave me a javascript runtime error saying "Object does not support this property or method". I'm not too sure why this doesn't work.
Basically, what i want to do is in this code is, select a cell, edit the cell with FullRowMode to false, take whatever is in the cell and the code behind will print it in the Textbox1. Thanks!
.aspx <eo:Grid ...ClientSideOnCellSelected="OnCellSelected">
Javascript: function OnCellSelected(grid) { var item = grid.getSelectedCell(); grid.raiseItemCommandEvent(item.getIndex(), "select"); //this is where it gave the error. }
.aspx.cs private void Grid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "select") { TextBox1.Text = e.Item.ToString(); } }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, grid.getSelectedCell() returns a GridCell object, not a GridItem object. GridCell object does not have getIndex method (GridItem has it). To correct the problem, you need to either call getItemIndex (instead of getIndex) on the GridCell object, or call getItem on GridCell object to get the GridItem object first, then call getIndex on the GridItem object. You can find more information about these objects at here: http://doc.essentialobjects.com/library/1/jsdoc.public.grid.aspxhttp://doc.essentialobjects.com/library/1/jsdoc.public.gridcell.aspxhttp://doc.essentialobjects.com/library/1/jsdoc.public.gridcolumn.aspxhttp://doc.essentialobjects.com/library/1/jsdoc.public.griditem.aspxHope this helps. Thanks
|
|
Rank: Member Groups: Member
Joined: 5/3/2010 Posts: 11
|
Hi, thanks for the suggestion! I tried using getItemIndex() and getItem().getIndex(). This time there is no error except it does not go to my event handler "private void Grid1_ItemCommand(object sender, GridCommandEventArgs e)" in the code behind at all (ie. I put a breakpoint at the eventhandler and it did not go there)! All its doing is highlighting the cell, and when the cell is highlighted the textbox did not print out the data in the cell. Can you please advice? Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That's probably because your event handler is not hooked up with the control at all. Try to select the Grid in design view, then go to property window, switch to the event tab and find ItemCommand event there. If it is empty, then nothing will get called. In that case you can either double click that entry to create a new handler or click the drop down to select your existing handler and get your existing handler hooked up.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/3/2010 Posts: 11
|
Hi, that was what i was looking for! Thanks very much!
|
|