My requirements are as follows:
A grid with inline add capability.
A column with delete capability.
No edit capability. In line or otherwise.
My problem is twofold. One it seems the only way to get the Insert/Cancel buttons to show up on inline add is to have an edit column defined. If this is not accurate please let me know.
The second problem is once I have a edit column the add works. But I do not want to edit. I have figured out how to hide the edit button but an empty column doesn't satisfy the customer either.
I have figured out how to direct the edit column to my delete function.... but my only problem remaining is I cannot change the edit pencil sprite to be the delete X sprite or delete Trashcan sprite.. In fact what I get is both icons overlaid on top of one another. Perhaps there is a property I am unaware of to remove the edit pencil image?
Please help with either how to get the correct image to display in my hijacked edit column or if there is a simpler approach to meet my requirements that I am unaware of.
Here is my code:
<telerik:RadGrid ID="Grid" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" Skin="Outlook" OnNeedDataSource="GetDataSource" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" OnItemCommand="GridOnCommand" OnPreRender="GridPreRender"> <MasterTableView IsFilterItemExpanded="True" CommandItemDisplay="Top" EditMode="InPlace"> <CommandItemSettings ShowAddNewRecordButton="true" AddNewRecordText="Add Record" /> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn FilterControlAltText="Filter Col1 column" HeaderText="Col1" UniqueName="Col1" DataField="Col1"> </telerik:GridBoundColumn> <telerik:GridBoundColumn FilterControlAltText="Filter Col2 column" HeaderText="Col2" UniqueName="Col2" DataField="Col2"> </telerik:GridBoundColumn> <telerik:GridBoundColumn FilterControlAltText="Filter Col3 column" HeaderText="Col3" UniqueName="Col3" DataField="Col3"> </telerik:GridBoundColumn> <telerik:GridBoundColumn FilterControlAltText="Filter Col4 column" HeaderText="Col4" UniqueName="Col3" DataField="Col4"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn"> </telerik:GridEditCommandColumn> </Columns> </MasterTableView> </telerik:RadGrid>Code Behind:
protected void GridPreRender(object sender, EventArgs e) { foreach (GridDataItem item in Grid.MasterTableView.Items) { ImageButton btn = (ImageButton)item["EditColumn"].Controls[0]; btn.CommandName = "Delete"; btn.CssClass = "rgDel"; btn.ToolTip = "Delete"; } }See the attached file for a picture of how this is currently outputting. The add in line column is expanded.