We have several places in our code where we need to move rows from one grid (Grid A) to another grid (Grid B) (with the same structure and on the same page). We currently have our code running fine with AJAX calls to server-side functions, but it would be a lot faster if we could do this with pure client-side calls (I don't see any reason why this wouldn't be possible seeing as we already have all the data loaded on the page that we need to do this). So far my JavaScript code has been working fine (I get the selected rows from the Grid A, move them to Grid B, and delete the rows from Grid A), but I have run into two issues:
1) Both grids have a Grid Template Column that have an Image and a RadToolTip control. The image is just a simple information button that displays the tooltip with a full description about the item. The column is defined like this:
<telerik:GridTemplateColumn SortExpression="Description" ItemStyle-HorizontalAlign="Center" HeaderText="Description" AllowFiltering="true" UniqueName="TemplateColumn"> |
<ItemTemplate> |
<asp:Image ID="ItemDescriptionImage" BorderWidth="0px" ImageUrl="~/images/desc.gif" Style="cursor: default;" runat="server"></asp:Image> |
<telerik:RadToolTip ID="rttItemDescription" runat="server" Width="150px" TargetControlID=" ItemDescriptionImage " RelativeTo="Element" Position="MiddleRight" ShowEvent="OnMouseOver"> |
<%# (Container.DataItem).Description %></telerik:RadToolTip> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
You can see the description is dynamically loaded for each item (late binding) with the <%# (Container.DataItem).Description %> code.
When I move the row from Grid A to Grid B, the tooltips are lost (I think because I am generating new ID's for the rows after they are moved to Grid B - this is based on the code I found on your Grid Client Demo page here). The JavaScript code looks like this:
var tableView = $find(gridId).get_masterTableView(); |
var dataItems = tableView.get_dataItems(); |
var columns = tableView.get_columns(); |
var newRow = tableView.get_element().insertRow(-1); |
var lastDataItem = dataItems[dataItems.length - 1]; |
var lastId = lastDataItem.get_id(); |
var lastIdIndex = parseInt(lastId.split("__")[1]) + 1; |
newRow.id = lastId.split("__")[0] + "__" + lastIdIndex; |
newRow.className = dataItems[dataItems.length - 1].get_element().className; |
Is there any way to move the tooltip with the row from Grid A to Grid B?
2) After rows have been moved from Grid A to Grid B, both grids lose the ability to Sort their data (I get the following exception):
The state information is invalid for this page and might be corrupted.
I noticed that the Grid Client Demo does not have Sorting turned on, so I'm not sure what to do to get this to work... This is probably the result of something I've done wrong, so I'm not as concerned about this issue yet.
Thank you very much for your help!