Hi,
I'm fairly new to the radgrid control, have a radgrid up and running, but I am having some trouble with performance as the number of records grows especially with filters. At the moment, I am using ObjectDataSource and Custom paging
The second parameter to the select clause is just an int that the code bases what order statuses to return by doing a contains on the list returned here's the code:
So this all works great until we start getting more and more records. After looking at the sample for 300000 records with linqdatasource, I thought I'd try that or using an entitydatasource. The only problem is I don't know how to pass in the filter of the list of ints for orderstatuses I want to show or how to use the where clause. I'm open to any suggestions that might imporove performance.
Thanks in advance
Dash
I'm fairly new to the radgrid control, have a radgrid up and running, but I am having some trouble with performance as the number of records grows especially with filters. At the moment, I am using ObjectDataSource and Custom paging
<
asp:ObjectDataSource
runat
=
"server"
ID
=
"OrderAdminOrderDataSource"
EnablePaging
=
"false"
SelectMethod
=
"GetAllOrdersByCountryISO2Code"
TypeName
=
"Organo.Web.Application.Facades.OrderAdminFacade"
DataObjectTypeName
=
"Organo.Web.Domain.Model.Entities.Order"
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"countryISO2Code"
/>
<
asp:Parameter
Name
=
"orderStatusFilterLevel"
/>
</
SelectParameters
>
</
asp:ObjectDataSource
>
protected
void
OrderAdminGrid_OnNeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
OrderAdminGrid.VirtualItemCount =
OrderAdminFacadeInstance.GetSelectRowCount(CountryDropDown.SelectedItem.Text,
HttpContext.Current.Items[
"OrderStatusFilterLevel"
].ToString());
var startRow = (ShouldApplySortFilterOrGroup())
? 0
: OrderAdminGrid.CurrentPageIndex*OrderAdminGrid.PageSize;
var maxRows = (ShouldApplySortFilterOrGroup())
? OrderAdminGrid.VirtualItemCount
: OrderAdminGrid.PageSize;
OrderAdminGrid.AllowCustomPaging = !ShouldApplySortFilterOrGroup();
OrderAdminGrid.DataSource =
OrderAdminFacadeInstance.GetAllOrdersByCountryISO2Code(CountryDropDown.SelectedItem.Text
, HttpContext.Current.Items[
"OrderStatusFilterLevel"
].ToString(), startRow,
maxRows);
}
The second parameter to the select clause is just an int that the code bases what order statuses to return by doing a contains on the list returned here's the code:
protected
void
OrderAdminGrid_OnNeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
//var filterexpression = OrderAdminGrid.MasterTableView.FilterExpression;
OrderAdminGrid.VirtualItemCount =
OrderAdminFacadeInstance.GetSelectRowCount(CountryDropDown.SelectedItem.Text,
HttpContext.Current.Items[
"OrderStatusFilterLevel"
].ToString());
var startRow = (ShouldApplySortFilterOrGroup())
? 0
: OrderAdminGrid.CurrentPageIndex*OrderAdminGrid.PageSize;
var maxRows = (ShouldApplySortFilterOrGroup())
? OrderAdminGrid.VirtualItemCount
: OrderAdminGrid.PageSize;
OrderAdminGrid.AllowCustomPaging = !ShouldApplySortFilterOrGroup();
OrderAdminGrid.DataSource =
OrderAdminFacadeInstance.GetAllOrdersByCountryISO2Code(CountryDropDown.SelectedItem.Text
, HttpContext.Current.Items[
"OrderStatusFilterLevel"
].ToString(), startRow,
maxRows);
//OrderAdminGrid.DataSource = OrderAdminFacadeInstance.GetAllOrdersByCountryISO2Code(CountryDropDown.SelectedItem.Text,
// HttpContext.Current.Items["OrderStatusFilterLevel"].ToString());
}
public
IQueryable<Order> GetAllOrdersByCountryISO2Code(
string
countryISO2Code,
string
orderStatusFilterLevel,
int
startRow,
int
pageSize)
{
var orders = countryISO2Code ==
"All"
? _orderRepository.GetAllFilteredByOrderStatus(GetOrderStatusFilter(Convert.ToInt32(orderStatusFilterLevel)))
.OrderByDescending(n => n.OrderDate).Skip(startRow).Take(pageSize)
: _orderRepository.GetAllFilteredByOrderStatus(GetOrderStatusFilter(Convert.ToInt32(orderStatusFilterLevel)), countryISO2Code)
.OrderByDescending(n => n.OrderDate).Skip(startRow).Take(pageSize);
return
orders;
}
public
int
GetSelectRowCount(
string
countryISO2Code,
string
orderStatusFilterLevel)
{
var orders = countryISO2Code ==
"All"
? _orderRepository.GetAllFilteredByOrderStatus(
GetOrderStatusFilter(Convert.ToInt32(orderStatusFilterLevel)))
.OrderByDescending(n => n.OrderDate)
: _orderRepository.GetAllFilteredByOrderStatus(
GetOrderStatusFilter(Convert.ToInt32(orderStatusFilterLevel)), countryISO2Code)
.OrderByDescending(n => n.OrderDate);
return
orders.Count();
}
and finally this method filters out the records based on whether they are in the filter list or not.
public
IQueryable<Order> GetAllFilteredByOrderStatus(List<
int
?> filter,
string
countryISO2Code)
{
int
monthlyOrder = Convert.ToInt16(Enums.OrderType.MonthlyOrder);
return
this
.FindAsQuery(
x =>
x.OrderType.OrderTypeId != monthlyOrder &&
x.ShippingAddress.Country.CountryISO2Code == countryISO2Code &&
filter.Contains(x.OrderStatusId));
}
So this all works great until we start getting more and more records. After looking at the sample for 300000 records with linqdatasource, I thought I'd try that or using an entitydatasource. The only problem is I don't know how to pass in the filter of the list of ints for orderstatuses I want to show or how to use the where clause. I'm open to any suggestions that might imporove performance.
Thanks in advance
Dash