I'm sure I am just missing some information here.
When a radGrid for Ajax goes into edit mode it shouldn't submit the form right?
I don't want the radGrid to refresh when it goes into edit mode.
The aspx and code behind is rather large. I'll try to cut it down to just the relevant pieces for you. The entire page is meant to mimik the behavior of the Windows File Explorer. What I'm trying to do now is put the grid into edit in place mode so the end user can edit the name of the folder or file prior to submitting to the server to do that action on the server. But like I said, when I put it into edit mode, it refreshes and returns the "empty data" template, not the edit mode template.
Here's the JavaScript code I use to put the grid into edit mode...
| function onGridRowClick(sender, args) { |
| var index = args.get_itemIndexHierarchical(); |
| // Put item into edit mode if clicked after selected (slow double-click) |
| if (currentSelectedGridRowIndex != null) { |
| if (index == currentSelectedGridRowIndex) { |
| var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); |
| masterTable.editItem(index); |
| } |
| } |
| currentSelectedGridRowIndex = index; |
| } |
Note that the currentSelectedGridRowIndex variable is global.
Anyhow, this works as I want, except then the masterTable.editItem(index); is called the form is submitted. (callback when ajax enabled) and my radGrid loses it's data.
Here's the markup for the radGrid...
| <telerik:RadGrid ID="RadGrid1" runat="server" |
| AutoGenerateColumns="False" |
| GridLines="None" |
| Skin="Office2007" |
| Width="100%" |
| BorderWidth="0px"> |
| <MasterTableView |
| clientDataKeyNames="Path,Name,Type" |
| EditMode="InPlace"> |
| <Columns> |
| <telerik:GridTemplateColumn HeaderText="Name" UniqueName="Name"> |
| <ItemTemplate> |
| <asp:Image ID="icon" runat="server" ImageAlign="absmiddle" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Icon") %>' AlternateText="icon" BorderWidth="0" /> |
| <asp:Label ID="name" runat="server" style="cursor:default;" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label> |
| </ItemTemplate> |
| <ItemStyle BorderStyle="None" Wrap="False" /> |
| <HeaderStyle Width="300px" /> |
| <EditItemTemplate> |
| <asp:TextBox ID="TextBox_NewName" runat="server"></asp:TextBox> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Size" UniqueName="Size"> |
| <ItemTemplate> |
| <asp:Label ID="size" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Size") %>'></asp:Label> |
| </ItemTemplate> |
| <ItemStyle BorderStyle="None" Width="100px" Wrap="False" /> |
| <HeaderStyle Width="100px" /> |
| <EditItemTemplate> |
| <asp:Label ID="size" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Size") %>'></asp:Label> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Modified" UniqueName="Modified"> |
| <ItemTemplate> |
| <asp:Label ID="modified" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Modified") %>'></asp:Label> |
| </ItemTemplate> |
| <ItemStyle BorderStyle="None" Width="230px" Wrap="False" /> |
| <HeaderStyle Width="230px" /> |
| <EditItemTemplate> |
| <asp:Label ID="modified" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Modified") %>'></asp:Label> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| <NoRecordsTemplate> |
| No Files or Folders. |
| </NoRecordsTemplate> |
| <ExpandCollapseColumn Visible="False" Resizable="False"> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <EditFormSettings> |
| <PopUpSettings ScrollBars="None" /> |
| </EditFormSettings> |
| </MasterTableView> |
| <ItemStyle BorderStyle="None" /> |
| <ClientSettings> |
| <Resizing AllowColumnResize="True" /> |
| <Selecting AllowRowSelect="True" /> |
| <ClientEvents OnRowClick="onGridRowClick" OnRowContextMenu="onGridRowContextMenu" OnRowDblClick="onGridRowDoubleClick" OnRowSelecting="onGridRowSelecting" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
These are the only two server-side event handlers...
| Private Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource |
| If RadTreeView1.SelectedNode IsNot Nothing Then |
| LoadGrid(RadTreeView1.SelectedNode.Value) |
| Else |
| LoadGrid(selectedPath) |
| End If |
| End Sub |
| Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated |
| If TypeOf e.Item Is GridDataItem Then |
| Dim dataItem As GridDataItem = TryCast(e.Item, GridDataItem) |
| e.Item.Attributes("onmousedown") = String.Format("onGridMouseDown(event, this,{0})", dataItem.DataSetIndex) |
| End If |
| End Sub |