I am using RadGrid which has both Filter and Pager.
When filtered 3 pages after that I clicked on page 2 then radgrid show page 2 of all data (filter not working at this time)
Sometimes, Filter also did not work properly. I don't know why. Can someone help me now?
_fileRadGrid.MasterTableView.FilterExpression always = empty so I have to use _fileStatusPendingRadGrid.MasterTableView.GetColumnSafe("Status").CurrentFilterValue to check HasFilter.
When I reload the page then pager and filter are not working properly. (I also code for another web app with filter and pager are working fine)
Please tell me why that code not working? the version of telerik is 2014.1.225.45
Inline:
<telerik:RadGrid ID="_fileRadGrid" runat="server" AutoGenerateColumns="False" AllowSorting="False"
AllowPaging="true" AllowFilteringByColumn="True" EnableAJAX="True" EnableViewState="True" ViewStateMode="Enabled"
EnableEmbeddedSkins="False" EnableEmbeddedBaseStylesheet="False" Skin="NitroCleo" PageSize="10" EnableLinqExpressions="False"
OnNeedDataSource="FileNeedDataSource"
OnItemDataBound="FileItemDataBound">
<ClientSettings>
<clientevents ongridcreating="OnGridCreated"/>
</ClientSettings>
<MasterTableView DataKeyNames="FileIdentifier" ClientDataKeyNames="FileIdentifier"
NoMasterRecordsText="No file" AllowFilteringByColumn="True" >
<PagerStyle Mode="NextPrevAndNumeric" PageButtonCount="6" />
<Columns>
<telerik:GridTemplateColumn HeaderStyle-Width="25px" AllowFiltering="False">
<ItemTemplate>
<asp:Label ID="_iconLabel" runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Status" UniqueName="Status" DataField="Status" AutoPostBackOnFilter="True"
CurrentFilterFunction="Contains">
<ItemTemplate>
<asp:HyperLink runat="server" ID="_statusLink"></asp:HyperLink>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Code Behind:
protected void FileNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
BindFileGrid(true);
}
private void BindFileGrid(bool needDataBind = false)
{
var listFile = new List<FileItem>();
int virtualItemCount = 0;
int pageSize = 0;
int pageIndex = 0;
try
{
if (!HasApplyFilter())
{
pageSize = _fileRadGrid.PageSize;
pageIndex = _fileRadGrid.CurrentPageIndex;
}
_fileRadGrid.AllowCustomPaging = !HasApplyFilter();
listFile = GetDataSourceForFile(pageIndex, pageSize, out virtualItemCount);
}
catch (Exception ex)
{
Log.Error(String.Format("An error while get file. Error: {0}", ex.Message));
}
_fileRadGrid.MasterTableView.PagerStyle.AlwaysVisible = virtualItemCount == 0 ? false : true;
if (listFile != null)
{
_fileRadGrid.DataSource = listFile;
_fileRadGrid.VirtualItemCount = virtualItemCount;
if (!needDataBind)
{
_fileRadGrid.DataBind();
}
}
}
Thanks for your reading!
When filtered 3 pages after that I clicked on page 2 then radgrid show page 2 of all data (filter not working at this time)
Sometimes, Filter also did not work properly. I don't know why. Can someone help me now?
_fileRadGrid.MasterTableView.FilterExpression always = empty so I have to use _fileStatusPendingRadGrid.MasterTableView.GetColumnSafe("Status").CurrentFilterValue to check HasFilter.
When I reload the page then pager and filter are not working properly. (I also code for another web app with filter and pager are working fine)
Please tell me why that code not working? the version of telerik is 2014.1.225.45
Inline:
<telerik:RadGrid ID="_fileRadGrid" runat="server" AutoGenerateColumns="False" AllowSorting="False"
AllowPaging="true" AllowFilteringByColumn="True" EnableAJAX="True" EnableViewState="True" ViewStateMode="Enabled"
EnableEmbeddedSkins="False" EnableEmbeddedBaseStylesheet="False" Skin="NitroCleo" PageSize="10" EnableLinqExpressions="False"
OnNeedDataSource="FileNeedDataSource"
OnItemDataBound="FileItemDataBound">
<ClientSettings>
<clientevents ongridcreating="OnGridCreated"/>
</ClientSettings>
<MasterTableView DataKeyNames="FileIdentifier" ClientDataKeyNames="FileIdentifier"
NoMasterRecordsText="No file" AllowFilteringByColumn="True" >
<PagerStyle Mode="NextPrevAndNumeric" PageButtonCount="6" />
<Columns>
<telerik:GridTemplateColumn HeaderStyle-Width="25px" AllowFiltering="False">
<ItemTemplate>
<asp:Label ID="_iconLabel" runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Status" UniqueName="Status" DataField="Status" AutoPostBackOnFilter="True"
CurrentFilterFunction="Contains">
<ItemTemplate>
<asp:HyperLink runat="server" ID="_statusLink"></asp:HyperLink>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Code Behind:
protected void FileNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
BindFileGrid(true);
}
private void BindFileGrid(bool needDataBind = false)
{
var listFile = new List<FileItem>();
int virtualItemCount = 0;
int pageSize = 0;
int pageIndex = 0;
try
{
if (!HasApplyFilter())
{
pageSize = _fileRadGrid.PageSize;
pageIndex = _fileRadGrid.CurrentPageIndex;
}
_fileRadGrid.AllowCustomPaging = !HasApplyFilter();
listFile = GetDataSourceForFile(pageIndex, pageSize, out virtualItemCount);
}
catch (Exception ex)
{
Log.Error(String.Format("An error while get file. Error: {0}", ex.Message));
}
_fileRadGrid.MasterTableView.PagerStyle.AlwaysVisible = virtualItemCount == 0 ? false : true;
if (listFile != null)
{
_fileRadGrid.DataSource = listFile;
_fileRadGrid.VirtualItemCount = virtualItemCount;
if (!needDataBind)
{
_fileRadGrid.DataBind();
}
}
}
Thanks for your reading!