So, I've been digging though the forums, looking for a solution, and havent found one yet. There might be a better solution for what I'm doing, and if there is, let me know. Otherwise, here goes.
I'm using the RadGrid from the RadControls Q3 2008. This grid lists the status of some items, and has two linkbuttons "Approve", and "Deny". In either case, when one of those buttons is clicked a RadWindow pops-up, and prompts the user to enter in a reason for the approve, or the deny. Problem is, when the rad-window closes, the ItemCommand event for the Grid never fires. The ItemCommand method is where my logic for persisting it to the database goes. How do I get this event to fire? I'm using the ItemCreated method to create the OnClientClick method. This brings me to another issue. I want to send the value of one of the GridCells to the RadWindow, I figure I'll modify the URL in the case as it's passed to the radwindow. ?id=14 for instance. I need to code that in the OnClientClick, but I dont think the Gird has those values yet. Here is the code I have:
The JavaScript on the main page:
The grid on the main page:
The .cs for the main page:
Ideas?
Thanks
I'm using the RadGrid from the RadControls Q3 2008. This grid lists the status of some items, and has two linkbuttons "Approve", and "Deny". In either case, when one of those buttons is clicked a RadWindow pops-up, and prompts the user to enter in a reason for the approve, or the deny. Problem is, when the rad-window closes, the ItemCommand event for the Grid never fires. The ItemCommand method is where my logic for persisting it to the database goes. How do I get this event to fire? I'm using the ItemCreated method to create the OnClientClick method. This brings me to another issue. I want to send the value of one of the GridCells to the RadWindow, I figure I'll modify the URL in the case as it's passed to the radwindow. ?id=14 for instance. I need to code that in the OnClientClick, but I dont think the Gird has those values yet. Here is the code I have:
The JavaScript on the main page:
| <telerik:RadCodeBlock ID="RCB" runat="server"> | |
| <script type="text/javascript"> | |
| function ShowInsertForm(rowNum) | |
| { | |
| window.radopen("approvalcomments.aspx?id=" + rowNum + "", null); | |
| //window.radopen(null, "radWindowComments"); | |
| return false; | |
| } | |
| function OnClientClose(radwindow) | |
| { | |
| if (radwindow != undefined) { | |
| var oValue = radwindow.argument; | |
| //alert(oValue); | |
| alert("I Fired"); | |
| ///return true; | |
| var aplhie = '<% = Label1.ClientID %>'; | |
| var lbl = document.getElementById(aplhie); | |
| lbl.innerHTML = "If I could, I would update that row you just clicked on, adding the comments: " + oValue; | |
| } | |
| } | |
| </script> | |
| </telerik:RadCodeBlock> |
The grid on the main page:
| <telerik:RadGrid ID="grid_Approval" runat="server" TabIndex="5" | |
| Skin="Office2007" AllowMultiRowSelection="True" AllowSorting="True" | |
| DataSourceID="oDataSource" GridLines="None" OnItemCommand="grid_Approval_ItemCommand" OnItemCreated="grid_Approval_ItemCreated" Ena > | |
| <HeaderContextMenu> | |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> | |
| </HeaderContextMenu> | |
| <MasterTableView DataSourceID="oDataSource" autogeneratecolumns="False"> | |
| <Columns> | |
| <telerik:GridButtonColumn | |
| CommandName="Approve" | |
| Text="Approve" | |
| UniqueName="Approve"> | |
| </telerik:GridButtonColumn> | |
| <telerik:GridButtonColumn | |
| CommandName="Deny" | |
| Text="Deny" | |
| UniqueName="Deny"> | |
| </telerik:GridButtonColumn> | |
| <telerik:GridBoundColumn DataField="ID" HeaderText="ID" | |
| SortExpression="ID" UniqueName="ID"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="EMP_ID" HeaderText="EMP_ID" | |
| SortExpression="EMP_ID" UniqueName="EMP_ID"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="ADDRESS" HeaderText="ADDRESS" | |
| SortExpression="ADDRESS" UniqueName="ADDRESS"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="JOB_NUMBER" HeaderText="JOB_NUMBER" | |
| SortExpression="JOB_NUMBER" UniqueName="JOB_NUMBER"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="JUSTIFICATION" HeaderText="JUSTIFICATION" | |
| SortExpression="JUSTIFICATION" UniqueName="JUSTIFICATION"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="AMOUNT" DataType="System.Decimal" | |
| HeaderText="AMOUNT" SortExpression="AMOUNT" UniqueName="AMOUNT"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="PC" HeaderText="PC" SortExpression="PC" | |
| UniqueName="PC"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="AWARD_NAME" HeaderText="AWARD_NAME" | |
| SortExpression="AWARD_NAME" UniqueName="AWARD_NAME"> | |
| </telerik:GridBoundColumn> | |
| <telerik:GridBoundColumn DataField="CREATOR" HeaderText="CREATOR" | |
| SortExpression="CREATOR" UniqueName="CREATOR"> | |
| </telerik:GridBoundColumn> | |
| </Columns> | |
| </MasterTableView> | |
| <FilterMenu> | |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> | |
| </FilterMenu> | |
| </telerik:RadGrid> |
The .cs for the main page:
| protected void grid_Approval_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) | |
| { | |
| string theCmd = e.CommandName.ToString(); | |
| if (theCmd == "Deny") | |
| { | |
| Label1.Text = "You are going to deny item " + e.Item.Cells[4].Text; | |
| } | |
| if (theCmd == "Approve") | |
| { | |
| Label1.Text = "You are going to approve item " + e.Item.Cells[4].Text; | |
| } | |
| } | |
| protected void grid_Approval_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) | |
| { | |
| if (e.Item is Telerik.Web.UI.GridDataItem) | |
| { | |
| Telerik.Web.UI.GridDataItem dataItem = e.Item as Telerik.Web.UI.GridDataItem; | |
| LinkButton button = dataItem["Approve"].Controls[0] as LinkButton; | |
| Label1.Text = e.Item.RowIndex.ToString(); | |
| button.OnClientClick = String.Format("return ShowInsertForm();"); | |
| button.Attributes["href"] = "#"; | |
| } | |
| } |
Ideas?
Thanks