Welcome Guest Search | Active Topics | Sign In | Register

raiseItemCommandEvent on Grid Options
MannyRosa
Posted: Saturday, December 1, 2012 3:50:00 AM
Rank: Member
Groups: Member

Joined: 9/6/2011
Posts: 26
I can use the available Grid demo "Custom Column - Advanced 2" to explain my problem (my grid is very similar to this demo):
On my server side I use the grid1.AddedItems to find the new items that have been added by the user to proceed to insert those to my database, however the grid1.AddedItems.Length is 0.
This happens if only the product selection is made and the quantity cell (which is optional and defaulted to 0 in my case) is not typed by the user. If the quantity cell is entered by the user then I have no problem with the grid1.AddedItems.Length.

However, if I remove the line:
grid.raiseItemCommandEvent(g_curItemIndex, "SelectProduct");
from the "on_product_change()" function, the grid1.AddedItems.Length works correctly (even without entering the quantity).

But I need to call the raiseItemCommandEvent to populate the Unit Price cell.

The same problem occurs with the grid1.ChangedItems collection when the user changes the product cell only and not the quantity cell.

How can I get these collections (AddedItems and ChangedItems) to work correctly even when the raiseItemCommandEvent is used and only the Combobox cell is selected by the user?
eo_support
Posted: Sunday, December 2, 2012 11:52:07 PM
Rank: Administration
Groups: Administration

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

I do not know how your on_product_changed is called. But you can try to call raiseItemCommandEvent insider a timer. It will be something like this:

Instead of doing:

Code: HTML/ASPX
grid.raiseItemCommandEvent(g_curItemIndex, "SelectProduct");


You can do:

Code: HTML/ASPX
setTimeout(function()
{
   grid.raiseItemCommandEvent(g_curItemIndex, "SelectProduct"); 
}, 10);


That allows the Grid to finishes whatever it was doing before raiseItemCommandEvent is called.

Thanks!
MannyRosa
Posted: Saturday, December 8, 2012 6:09:34 AM
Rank: Member
Groups: Member

Joined: 9/6/2011
Posts: 26
I have tried with the timeout function (even increasing from 10 to 10000) but the result is the same.

I tried moving grid.raiseItemCommandEvent(g_curItemIndex, "SelectTeam") to my on_end_edit(cell) function and to my on_column_gettext function but the result is the same in both cases.

I removed all the code on the C# function grvTeams_ItemCommand(object sender, EO.Web.GridCommandEventArgs e), trying to see is something was happenning there that could cause the problem but the result is the same.

In all cases above Im getting grvTeams.AddedItems.Length = 0 when Im actually inserting 4 new rows.

The only way I can get grvTeams.AddedItems.Length to have 4 is if I remove grid.raiseItemCommandEvent(g_curItemIndex, "SelectTeam").

Here is a copy of the 3 pieces of my code:

<eo:CustomColumn ClientSideBeginEdit="on_begin_edit"
ClientSideEndEdit="on_end_edit" ClientSideGetText="on_column_gettext"
DataField="TeamName" HeaderText="Team Name" Width="225">
<CellStyle CssText="padding-left:8px;padding-top:2px; color:#336699;white-space:nowrap; width:225px; text-align: left;" />
<editortemplate>
<select ID="ddlTeam" onchange="on_team_change()">
<asp:Repeater ID="Teams" Runat="server">
<ItemTemplate>
<option value='<%#DataBinder.Eval(Container.DataItem, "TeamID")%>'>
<%#DataBinder.Eval(Container.DataItem, "TeamName")%></option>
</ItemTemplate>
</asp:Repeater>
</select>
</editortemplate>
<CellStyle CssText="padding-left:8px;padding-top:2px; color:#336699;white-space:nowrap; width:225px; text-align: left;" />
</eo:CustomColumn>



function on_team_change() {
if (g_curItemIndex >= 0) {
var grid = eo_GetObject("grvTeams");
setTimeout(function () {
grid.raiseItemCommandEvent(g_curItemIndex, "SelectTeam");
}, 10);
}
}




protected void grvTeams_ItemCommand(object sender, EO.Web.GridCommandEventArgs e)
{
DataTable rsData = new DataTable();
clsScores oTeams = new clsScores();

int TeamID = 0;
if (e.Item.Cells[4].Value != "") { TeamID = Convert.ToInt32(e.Item.Cells[4].Value); }
try
{
rsData = oTeams.GetTeams(TournamentID.ToString(), 0, TeamID);
if (rsData.Rows.Count != 0)
{
e.Item.Cells[2].Value = rsData.Rows[0]["TeamTxtID"].ToString();
e.Item.Cells[3].Value = rsData.Rows[0]["TeamID"].ToString();
e.Item.Cells[4].Value = rsData.Rows[0]["TeamName"].ToString();
e.Item.Cells[6].Value = rsData.Rows[0]["CoachName"].ToString();
e.Item.Cells[7].Value = rsData.Rows[0]["CoachPhone_Formatted"].ToString();
}
}
catch (Exception ex)
{
MsgBox("ERROR Reading Team info:" + ex.Message);
}
finally
{
oTeams = null;
}
}

eo_support
Posted: Monday, December 10, 2012 9:41:28 AM
Rank: Administration
Groups: Administration

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

Your code looks fine to us. The problem most likely occurs because you rebind your Grid when the page posts back. When you rebind the Grid, it wipes out everything.

If that's not the problem, you can isolate the problem into a test project and send the test project to us. Once we have that we will be happy to look into it.

Thanks!


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.