Dutchbasterd
New Member
I'm trying to delete a row from a RadGrid client-side using the deleteItem() method without doing a postback. But the row doesn't get deleted... it still appears in the list. What am I doing wrong? Please help!\[code\] <telerik:RadGrid ID="rgvAlerts" runat="server" CssClass="RadGrid2" AllowSorting="True" EnableViewState="false" AutoGenerateColumns="False" OnNeedDataSource="rgvAlerts_NeedDataSource" OnItemDataBound="rgvAlerts_ItemDataBound" > <ClientSettings AllowKeyboardNavigation="True"> <Selecting AllowRowSelect="True" EnableDragToSelectRows="True"/> <ClientEvents OnCommand="rgvAlerts_OnCommand" /> </ClientSettings> <MasterTableView DataKeyNames="MYID" ClientDataKeyNames="MYID" > <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn HeaderStyle-Width="16%" HeaderText="Timestamp" DataField="Timestamp" /> <telerik:GridBoundColumn HeaderStyle-Width="4%" HeaderText="Field1" DataField="Field1" /> <telerik:GridBoundColumn HeaderStyle-Width="32%" HeaderText="Field2" DataField="Field2" /> <telerik:GridBoundColumn HeaderStyle-Width="6%" HeaderText="Field3" DataField="Field3" /> <telerik:GridBoundColumn HeaderStyle-Width="6%" HeaderText="Field4" DataField="Field4" /> <telerik:GridBoundColumn HeaderStyle-Width="33%" HeaderText="Field5" DataField="Field5" /> <telerik:GridTemplateColumn HeaderStyle-Width="5%" HeaderText="Clear" UniqueName="Clear" > <ItemTemplate> <telerik:RadButton ID="btnClearAlert" runat="server" Height="25px" Width="26px" AutoPostBack="false"> <Image ImageUrl="" /> </telerik:RadButton> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> <FilterMenu EnableImageSprites="False"></FilterMenu> </telerik:RadGrid>//Code behind for ItemDataBoundprotected void rgvAlerts_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){ if (e.Item is Telerik.Web.UI.GridDataItem) { Telerik.Web.UI.GridDataItem gridDataItem = (Telerik.Web.UI.GridDataItem)e.Item; Alert datAlert = (Alert)gridDataItem.DataItem; //Clear button RadButton btnClearAlert = (RadButton)gridDataItem["Clear"].FindControl("btnClearAlert"); btnClearAlert.Image.ImageUrl = "Image.png"; btnClearAlert.CommandArgument = gridDataItem.ItemIndex + ";" + datAlert.Timestamp + ";" + datAlert.Field1 + ";" + datAlert.Field2 + ";" + datAlert.Field3; //Use these values to update database using web service from client-side btnClearAlert.OnClientClicked = "rgvAlerts_OnClientClicked"; }}//Client-side Click eventfunction rgvAlerts_OnClientClicked(sender, args) { var params = args.get_commandArgument().split(";"); var masterTable = $find("<%:rgvAlerts.ClientID %>").get_masterTableView(); var returnVal = masterTable.deleteItem(masterTable.get_dataItems()[params[0]].get_element()); //***returnVal returns false?*** //I will add a call to web service here}//Client-side OnCommand eventfunction rgvAlerts_OnCommand(sender, args) { if (args.get_commandName() == "Delete") { args.set_cancel(true); //Prevent postback }}\[/code\]