Hi,
I have a radGrid with 50 items per page(total 200 rows) splitted into four pages. when i filter a column with some value, i am getting the results properly for the current page. But when i move to another page(prev or forward), the grid is not retaining the filter value, and grid is bound with complete 200 items. Can you please help me with this issue?
Thanks,
Farjana
I have a radGrid with 50 items per page(total 200 rows) splitted into four pages. when i filter a column with some value, i am getting the results properly for the current page. But when i move to another page(prev or forward), the grid is not retaining the filter value, and grid is bound with complete 200 items. Can you please help me with this issue?
Thanks,
Farjana
12 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 05 Dec 2013, 10:17 AM
Hi Farjana,
Please make sure that you are binding the RadGrid using Advanced Data-binding (using NeedDataSource event). Below is a sample code snippet That i tried which works fine. Please try and provide your full code snippet if this doesn't help.
ASPX:
C#:
Thanks,
Princy
Please make sure that you are binding the RadGrid using Advanced Data-binding (using NeedDataSource event). Below is a sample code snippet That i tried which works fine. Please try and provide your full code snippet if this doesn't help.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
AllowPaging
=
"true"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
AllowFilteringByColumn
=
"true"
>
<
MasterTableView
DataKeyNames
=
"OrderID"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"OrderID"
DataField
=
"OrderID"
HeaderText
=
"OrderID"/
>
<
telerik:GridBoundColumn
DataField
=
"ShipCity"
HeaderText
=
"ShipCity"
UniqueName
=
"ShipCity"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable(
"SELECT OrderID,ShipCity FROM Orders"
);
}
public
DataTable GetDataTable(
string
query)
{
String ConnString = ConfigurationManager.ConnectionStrings[
"Northwind_newConnectionString3"
].ConnectionString;
SqlConnection conn =
new
SqlConnection(ConnString);
SqlDataAdapter adapter =
new
SqlDataAdapter();
adapter.SelectCommand =
new
SqlCommand(query, conn);
DataTable myDataTable =
new
DataTable();
conn.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
conn.Close();
}
return
myDataTable;
}
Thanks,
Princy
0
Farjana
Top achievements
Rank 1
answered on 16 Jan 2014, 06:53 AM
Hi Princy,
Thanks. I am binding datasource for the grid in Need DataSource event only. But still i have problem with pagination while filtering or sorting. I am using custom pagination options as given below. Are there any possibility that filters or sorting not working because of this?
protected void Managegridview_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
var dropDown = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
var totalCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;
var sizes = new Dictionary<string, string>()
{
{"10", "10"},
{"20", "20"},
{"50", "50"}
};
if (totalCount > 100)
{
sizes.Add("100", "100");
}
if (totalCount > 200)
{
sizes.Add("200", "200");
}
sizes.Add("All", totalCount.ToString());
dropDown.Items.Clear();
if (sizes.Where(x => x.Key == e.Item.OwnerTableView.PageSize.ToString()).FirstOrDefault().Value == null)
{
sizes.Add(e.Item.OwnerTableView.PageSize.ToString(), e.Item.OwnerTableView.PageSize.ToString());
}
foreach (var size in sizes)
{
var cboItem = new RadComboBoxItem() { Text = size.Key, Value = size.Value };
cboItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
dropDown.Items.Add(cboItem);
}
dropDown.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
}
}
Thanks,
Farjana
Thanks. I am binding datasource for the grid in Need DataSource event only. But still i have problem with pagination while filtering or sorting. I am using custom pagination options as given below. Are there any possibility that filters or sorting not working because of this?
protected void Managegridview_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
var dropDown = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
var totalCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;
var sizes = new Dictionary<string, string>()
{
{"10", "10"},
{"20", "20"},
{"50", "50"}
};
if (totalCount > 100)
{
sizes.Add("100", "100");
}
if (totalCount > 200)
{
sizes.Add("200", "200");
}
sizes.Add("All", totalCount.ToString());
dropDown.Items.Clear();
if (sizes.Where(x => x.Key == e.Item.OwnerTableView.PageSize.ToString()).FirstOrDefault().Value == null)
{
sizes.Add(e.Item.OwnerTableView.PageSize.ToString(), e.Item.OwnerTableView.PageSize.ToString());
}
foreach (var size in sizes)
{
var cboItem = new RadComboBoxItem() { Text = size.Key, Value = size.Value };
cboItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
dropDown.Items.Add(cboItem);
}
dropDown.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
}
}
Thanks,
Farjana
0
Princy
Top achievements
Rank 2
answered on 16 Jan 2014, 07:42 AM
Hi Farjana,
I'm not able to replicate the issue. Filtering functionality is not affected by paging when using NeedDataSource event. Can you check to see if the correct datasource is passed in each case. This behavior might happen if you are filtering one source of data but paging on another. Can you provide your complete code snippet.
ASPX:
C#:
Thanks,
Princy
I'm not able to replicate the issue. Filtering functionality is not affected by paging when using NeedDataSource event. Can you check to see if the correct datasource is passed in each case. This behavior might happen if you are filtering one source of data but paging on another. Can you provide your complete code snippet.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
AllowPaging
=
"true"
PageSize
=
"50"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
AllowFilteringByColumn
=
"true"
OnItemCreated
=
"RadGrid1_ItemCreated"
>
<
MasterTableView
DataKeyNames
=
"OrderID"
>
<
PagerStyle
AlwaysVisible
=
"true"
/>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"OrderID"
DataField
=
"OrderID"
HeaderText
=
"OrderID"
/>
<
telerik:GridBoundColumn
DataField
=
"ShipCity"
HeaderText
=
"ShipCity"
UniqueName
=
"ShipCity"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridPagerItem)
{
var dropDown = (RadComboBox)e.Item.FindControl(
"PageSizeComboBox"
);
var totalCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;
var sizes =
new
Dictionary<
string
,
string
>()
{
{
"10"
,
"10"
},
{
"20"
,
"20"
},
{
"50"
,
"50"
}
};
if
(totalCount > 100)
{
sizes.Add(
"100"
,
"100"
);
}
if
(totalCount > 200)
{
sizes.Add(
"200"
,
"200"
);
}
sizes.Add(
"All"
, totalCount.ToString());
dropDown.Items.Clear();
foreach
(var size
in
sizes)
{
var cboItem =
new
RadComboBoxItem() { Text = size.Key, Value = size.Value };
cboItem.Attributes.Add(
"ownerTableViewId"
, e.Item.OwnerTableView.ClientID);
dropDown.Items.Add(cboItem);
}
dropDown.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected =
true
;
}
}
Thanks,
Princy
0
Farjana
Top achievements
Rank 1
answered on 16 Jan 2014, 08:39 AM
Hi,
Please find the need data source event and grid in aspx. I hope i am binding the same datasource for filters as well as paging. I guess while paging it load the entire result set without considering filters.
protected void Managegridview_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
switch (id)
{
//Order Details
case PENDING_SLOT_PLANNING:
{
// CR: Can we take it from userDetail object.Otherwise check for null.
// Avoid Convert.ToString.
userRoles = userDetails.UserRoles;
if (userRoles.Any(r => r.Equals(UserRoles.PM)))
{
Response.Redirect(url);
}
else
{
status = ORDR_CRTD;
Managegridview.DataSource = objManageViews.GetOrdersList(viewId, userId, status);
}
break;
}
case PENDING_APPROVAL:
{
status = ORDR_PLND;
Managegridview.DataSource = objManageViews.GetOrdersList(viewId, userId, status);
break;
}
case AWAITING_ENHANCEMENT:
{
status = ORDR_APRV;
Managegridview.DataSource = objManageViews.GetOrdersList(viewId, userId, status);
break;
}
case PENDING_MILESTONE_DET:
{
phasesViewId = PM_VIEW_ID;
List<
int
> statusList = new List<
int
>();
statusList.Add(TECH_DTLS);
statusList.Add(COMP_START);
statusList.Add(COMP_CMPL);
statusList.Add(QUAL_STRT);
statusList.Add(QUAL_CMPL);
statusList.Add(STST_STRT);
statusList.Add(STST_CMPL);
statusList.Add(ATST_STRT);
statusList.Add(ATST_CMPL);
statusList.Add(PHSE_MILE_CMPL);
Managegridview.DataSource = objManageViews.GetOrdersListMilestoneDetails(phasesViewId, userId, statusList);
//status = TECH_DTLS;
//Managegridview.DataSource = objManageViews.GetOrdersList(viewId, userId, status);
break;
}
case AWAITING_DELIVERY_CONFIRMATION:
{
status = PHSE_MILE_CMPL;
delId = DEL_CONFIRMATION;
Managegridview.DataSource = objManageViews.GetOrdersList(delId, userId, status);
break;
}
case PENDING_CANCEL_APPROVAL:
{
status = REQU_CNCL;
Managegridview.DataSource = objManageViews.GetOrdersList(viewId, userId, status);
break;
}
//Administration Details
case VENDOR_PRODUCT_SCHEDULE:
{
Radbtnadd.Visible = false;
Managegridview.DataSource = objManageViews.GetManageData(id, userId);
break;
}
case MANAGE_ORDERS:
{
for (int count = 0; count < businessFunctions.Count; count++)
{
if (businessFunctions[count].BusinessFunctionName.Equals(BusinessFunctionNames.InitialOrder) && businessFunctions[count].AuthorizationType.ToString().Equals(EDIT))
{
Radbtnadd.Visible = true;
}
else
{
//do nothing
}
}
Managegridview.DataSource = objManageViews.GetOrdersList(id, userId, status);
break;
}
case MANAGE_PRODUCT_PROJECT_MAP:
{
Radbtnadd.Visible = (vpId != "") ? false : true;
Managegridview.DataSource = objManageViews.GetManageData(id, userId);
break;
}
//Administration Details
default:
{
if (userDetails.ClassicAdmin || userDetails.NDSAdmin || vmFlag)
{
Radbtnadd.Visible = true;
}
Managegridview.DataSource = objManageViews.GetManageData(id, userId);
break;
}
}
}
<
telerik:RadGrid
ID
=
"Managegridview"
runat
=
"server"
AllowPaging
=
"true"
AllowSorting
=
"true"
GridLines
=
"None"
OnNeedDataSource
=
"Managegridview_NeedDataSource"
OnItemDataBound
=
"Managegridview_ItemDataBound"
AllowFilteringByColumn
=
"true"
CellSpacing
=
"0"
Skin
=
"WebBlue"
OnPreRender
=
"Managegridview_PreRender"
OnItemCreated
=
"Managegridview_ItemCreated"
PageSize
=
"50"
AutoSetColumnWidth
=
"false"
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
ClientSettings
EnableRowHoverStyle
=
"true"
AllowColumnsReorder
=
"true"
ReorderColumnsOnClient
=
"true"
AllowColumnHide
=
"true"
ColumnsReorderMethod
=
"Reorder"
>
<
Resizing
AllowColumnResize
=
"true"
AllowResizeToFit
=
"true"
ResizeGridOnColumnResize
=
"false"
/>
<
Selecting
AllowRowSelect
=
"true"
/>
<
ClientEvents
OnFilterMenuShowing
=
"filterMenushowing"
/>
</
ClientSettings
>
<
HeaderStyle
Width
=
"100px"
/>
<
MasterTableView
GridLines
=
"None"
Width
=
"100%"
AllowMultiColumnSorting
=
"true"
>
<
Columns
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
Visible
=
"false"
UniqueName
=
"GridCheckBoxColumn"
HeaderText
=
"Select"
HeaderStyle-Width
=
"80px"
>
<
HeaderTemplate
>
<
asp:CheckBox
id
=
"chkHeader"
runat
=
"server"
onclick
=
"javascript:HeaderClickAboveGrid(this);"
Text
=
"Select"
/>
</
HeaderTemplate
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"chkTest"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
></
CommandItemSettings
>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Visible
=
"True"
FilterControlAltText
=
"Filter ExpandColumn column"
Created
=
"True"
>
</
ExpandCollapseColumn
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
<
PagerStyle
PageSizeControlType
=
"RadComboBox"
Mode
=
"NextPrevAndNumeric"
EnableSEOPaging
=
"True"
AlwaysVisible
=
"true"
></
PagerStyle
>
</
MasterTableView
>
<
PagerStyle
PageSizeControlType
=
"RadComboBox"
></
PagerStyle
>
<
FilterMenu
OnClientShown
=
"MenuShowing"
/>
<%--<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>--%>
</
telerik:RadGrid
>
0
Shinu
Top achievements
Rank 2
answered on 16 Jan 2014, 08:55 AM
.
0
Accepted
Princy
Top achievements
Rank 2
answered on 16 Jan 2014, 08:56 AM
Hi Farjana,
As far as i know, it is a limitation of the RadGrid control that it does not support filtering and sorting with SEOPaging. Can you please set EnableSEOPaging="false" and check if the code works fine.
Thanks,
Princy
As far as i know, it is a limitation of the RadGrid control that it does not support filtering and sorting with SEOPaging. Can you please set EnableSEOPaging="false" and check if the code works fine.
Thanks,
Princy
0
Farjana
Top achievements
Rank 1
answered on 16 Jan 2014, 09:47 AM
Thanks Princy, It works fine.
I would like to know disabling that "EnableSOEPaging" in pager style will affect any other functionality of grid.?
Thanks,
Farjana
I would like to know disabling that "EnableSOEPaging" in pager style will affect any other functionality of grid.?
Thanks,
Farjana
0
Princy
Top achievements
Rank 2
answered on 18 Jan 2014, 03:12 AM
Hi Farjana,
When you set EnableSEOPaging to True, the grid always handles paging using query strings. When it is False, the grid does not use SEO paging unless it detects a crawler. Setting it doesn't affect any other grid functionality. To know more on this topic got through this documentation on SEO Paging.
Thanks,
Princy
When you set EnableSEOPaging to True, the grid always handles paging using query strings. When it is False, the grid does not use SEO paging unless it detects a crawler. Setting it doesn't affect any other grid functionality. To know more on this topic got through this documentation on SEO Paging.
Thanks,
Princy
0
Farjana
Top achievements
Rank 1
answered on 21 Jan 2014, 12:46 PM
Hi Princy,
Thanks. The content of the radgrid id getting right aligned. Even i dont have any css class. I have tried some options like following:
<telerik:RadGrid ID="SPCalculatedValues" runat="server" AutoGenerateColumns="true"
OnColumnCreated="SPCalculatedValues_ColumnCreated" Skin="Office2007"
Width="100%" OnItemDataBound="SPCalculatedValues_ItemDataBound" HeaderStyle-HorizontalAlign="center" ItemStyle-HorizontalAlign="center">
<ClientSettings EnableAlternatingItems="false">
</ClientSettings>
<MasterTableView TableLayout="Fixed">
</MasterTableView>
</telerik:RadGrid>
I have attached the screenshot.Please tell me how to make it center aligned
Thanks. The content of the radgrid id getting right aligned. Even i dont have any css class. I have tried some options like following:
<telerik:RadGrid ID="SPCalculatedValues" runat="server" AutoGenerateColumns="true"
OnColumnCreated="SPCalculatedValues_ColumnCreated" Skin="Office2007"
Width="100%" OnItemDataBound="SPCalculatedValues_ItemDataBound" HeaderStyle-HorizontalAlign="center" ItemStyle-HorizontalAlign="center">
<ClientSettings EnableAlternatingItems="false">
</ClientSettings>
<MasterTableView TableLayout="Fixed">
</MasterTableView>
</telerik:RadGrid>
I have attached the screenshot.Please tell me how to make it center aligned
0
Princy
Top achievements
Rank 2
answered on 22 Jan 2014, 09:36 AM
Hi Farjana,
The code looks fine, can you make sure you have not set any ItemStyle-Width somewhere in your code. It is not recommended to use ItemStyle-Width for setting column widths. Only HeaderStyle-Width should be used.
ASPX:
Thanks,
Princy
The code looks fine, can you make sure you have not set any ItemStyle-Width somewhere in your code. It is not recommended to use ItemStyle-Width for setting column widths. Only HeaderStyle-Width should be used.
ASPX:
<
telerik:GridBoundColumn
. . >
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:GridBoundColumn
>
Thanks,
Princy
0
Farjana
Top achievements
Rank 1
answered on 22 Jan 2014, 12:14 PM
Hi Princy,
I tried the previous answer, but still problem persists. Actually, my grid is having dynamic binding of columns.
Ex. Initially if number of columns is 20, I can change it to 30,40 or 60....When i change the number of columns to be displayed as 50 or 60, the problem of alignment happens
I tried the previous answer, but still problem persists. Actually, my grid is having dynamic binding of columns.
Ex. Initially if number of columns is 20, I can change it to 30,40 or 60....When i change the number of columns to be displayed as 50 or 60, the problem of alignment happens
0
Princy
Top achievements
Rank 2
answered on 23 Jan 2014, 11:56 AM
Hi Farjana,
Unfortunately I'm not able to replicate the issue at my side.
Thanks,
Princy
Unfortunately I'm not able to replicate the issue at my side.
Thanks,
Princy