In order to make my pages containing RadGrids more responsive, I load the page with no data and then retrieve the data in a postback.
This worked great until I tried running it with the latest Telerik UI controls (2016 Q1). Now, the remove_load does not seem to work, so the data is continually reloaded.
Any ideas?
The code on my aspx page is as follows:
<script type=
"text/javascript"
>
function
rebindGrid(clientid) {
var
grid = $find(clientid);
if
(grid ==
null
)
return
;
if
(
typeof
(grid.get_masterTableView) !=
"function"
)
return
;
var
masterTable = grid.get_masterTableView();
if
(masterTable !=
null
)
masterTable.rebind();
}
function
rebindPageGrid() {
Sys.Application.remove_load(rebindPageGrid);
rebindGrid(
"<%= AccountGrid.ClientID %>"
);
}
Sys.Application.add_load(rebindPageGrid);
</script>
The code behind looks like:
protected
void
OnAccountGridNeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
if
(Page.IsPostBack)
{
AccountGrid.DataSource = GetAccountList();
AccountGrid.MasterTableView.NoMasterRecordsText =
"No records to display"
;
}
else
{
AccountGrid.DataSource =
new
List<Account>();
AccountGrid.MasterTableView.NoMasterRecordsText =
"Loading Data..."
;
}
}