| if (this.ContentAwarePager != null) |
| { |
| AjaxUpdatedControl ucgrid = new AjaxUpdatedControl(); |
| ucgrid.ControlID = this.ID; |
| AjaxUpdatedControl ucpager = new AjaxUpdatedControl(); |
| ucpager.ControlID = (this.ContentAwarePager as WebControl).ID; |
| AjaxSetting gridtopager = new AjaxSetting(); |
| gridtopager.AjaxControlID = this.ID; |
| gridtopager.UpdatedControls.Add(ucgrid); |
| gridtopager.UpdatedControls.Add(ucpager); |
| ram.AjaxSettings.Add(gridtopager); |
| AjaxSetting pagertogrid = new AjaxSetting(); |
| gridtopager.AjaxControlID = (this.ContentAwarePager as WebControl).ID; |
| gridtopager.UpdatedControls.Add(ucgrid); |
| gridtopager.UpdatedControls.Add(ucpager); |
| ram.AjaxSettings.Add(pagertogrid); |
| } |
| sub bindgrid() Dim d As DataTable = CType(Cache("MyCache"), Data.DataTable) |
| If d Is Nothing Then |
| d = functions.dt("Select top 100* from table") |
| Cache.Insert("MyCache", d, Nothing, DateTime.Now.AddSeconds(30), TimeSpan.Zero) |
| status.innerhtml = "data loaded from database" |
| Else |
| status.innerhtml = "Data loaded from cache" |
| End If |
| RadGrid1.DataSource = d end sub |
I am calling the sub from within the needdatasource event. so now the grid loads either cached or fresh data. I am handling paging via calling bindgrid() again and setting pageindex to newpageindex.
This works fine. When I go into edit mode and incorporate the GridEditableitem method and update the selected row this also works fine except that the cached data now no longer matches the updated data. until the cache is rebuilt or I manually remove the cache on updated.
| If e.CommandName = "Update" Then |
| Dim ei As GridEditableItem = TryCast(e.Item, GridEditableItem) |
| Dim pk As String = ei.OwnerTableView.DataKeyValues(ei.ItemIndex)("keyid").ToString() |
| Dim empid As String = TryCast(ei("Emp_ID").Controls(0), TextBox).Text |
| Dim sql As String = "update table set emp_id = '" & empid & "' where keyid = " & pk |
| functions.Scalar(sql) |
| Cache.Remove("MyCache") 'If I don't kill the cache I end up with the old values. |
| bindgrid() |
| End If |
Do you have any method or trick to updating the grid to the new values without having to rebuild the cache? I suppose I could somehow extract the datatable from the cache, loop through the datatable, find the affected row, somehow update the column and reset the grid... but that seems pretty laborious.
Following are 2 paneltems in the panel bar. On button click of btnAddAccountChecking I am trying to expand CheckingAddUserControl panel item. It does expand the panel item but after that it breaks on Telerik general undefined object null javascript error .
This is the code to attach java function for CheckingAddUserControl Client side processing.
Dim btnAddChecking As ImageButton = CType(pnlTopLevel.Items().FindItemByValue("CheckingAdd").Items().FindItemByValue("CheckingAddbtn").FindControl("btnAddAccountChecking"), ImageButton)
Dim openWinScript As String = "SetVisibility('CheckingAddUserControl');"
btnAddChecking.OnClientClick = openWinScript
This is the JavaScript Function:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function SetVisibility(itemValue) {
var panelBar = $find("<%= pnlBarAccounts.ClientID %>");
var panelItem = panelBar.findItemByValue(itemValue);
panelItem.expand();
}
</script>
</telerik:RadCodeBlock>
These are the panelitems
<telerik:RadPanelItem value="CheckingAdd" runat="server" Text="CheckingAdd" Expanded="true" style="display:none;">
<Items>
<telerik:RadPanelItem value="CheckingAddbtn" runat="server" Text="" Expanded="true">
<ItemTemplate>
<br />
<asp:ImageButton ID="btnAddAccountChecking" runat="server" />
</ItemTemplate>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelItem>
<telerik:RadPanelItem value="CheckingAddUserControl" runat="server" Expanded="false" Visible="true">
<Items>
<telerik:RadPanelItem runat="server" Expanded="true" >
<ItemTemplate>
<UC1:CheckingAcct ID="CheckingAcct1" runat="server" AcctID="0" />
</ItemTemplate>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelItem>
| <asp:ImageButton ID="btn_ExportCSV" runat="server" |
| OnClick="btn_ExportCSV_Click" BorderColor="#F0A54E" |
| BorderStyle="Ridge" |
| ImageUrl="~/images/export_csv.jpg" /> |
| <asp:ImageButton ID="btn_ExportEXCEL" runat="server" |
| OnClick="btn_ExportEXCEL_Click" BorderColor="#F0A54E" |
| BorderStyle="Ridge" |
| ImageUrl="~/images/export_excel.jpg" /> |
| <asp:ImageButton ID="btn_ExportWORD" runat="server" |
| OnClick="btn_ExportWORD_Click" BorderColor="#F0A54E" |
| BorderStyle="Ridge" |
| ImageUrl="~/images/export_word.jpg" /> |
| Protected Sub btn_ExportEXCEL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_ExportEXCEL.Click |
| ConfigureExport() |
| grid_applications.MasterTableView.ExportToExcel() |
| End Sub |
| Protected Sub btn_ExportWORD_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_ExportWORD.Click |
| ConfigureExport() |
| grid_applications.MasterTableView.ExportToWord() |
| End Sub |
| Protected Sub btn_ExportCSV_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_ExportCSV.Click |
| ConfigureExport() |
| grid_applications.MasterTableView.ExportToCSV() |
| End Sub |
| Public Sub ConfigureExport() |
| For x = 2 To 22 'display only columns I want |
| grid_applications.MasterTableView.Columns(x).Visible = True |
| Next |
| End Sub |
Line 131: BorderStyle="Ridge"
Line 132: ImageUrl="~/images/export_word.jpg" />
Line 133:<telerik:RadGrid ID="grid_applications" runat="server" DataSourceID="sqlds_Applications"
Line 134: GridLines="None" Width="1100px" AllowFilteringByColumn="True"
Line 135: AllowPaging="True" AllowSorting="True" PageSize="30" ShowGroupPanel="True">