I'm using a nested RadGrids, three layers deep, where the third RadGrid is databinding to a database table with around 300,000 records. I only need to retrieve a few records based on filter criteria that I enter in the filter boxes at the top of the columns. If there is no text in the filter boxes, then I don't want to retrieve any records from the database at all. I only need to retrieve records once the user has typed in some filter criteria.
I'm having three issues with this:
1. RadGrid is retrieving the records at initial load, without the user having entered any filter criteria. I need the RadGrid to be blank prior to the user entering the filter criteria.
2. Upon entering the filter criteria, RadGrid is retrieving all the records form the DB (around 300,000), and then filtering them, rather than the other way around.
3. I would like the "onitemcommand="CustomMatches_TelerikRadGrid3_ItemCommand"" event to be fired before the "CustomMatches_TelerikRadGrid3_NeedDataSource" event. Is there a way to switch their order of execution?
The relevant code segments are as follows:
The line
These variables are defined at the top of the code behind page, right above the "Page_Load" method, in order to keep track of the state of different events/objects, between the different functions on the page.
Is this enough information to help answer my questions? I can provide additional information if need be.
Thanks!
I'm having three issues with this:
1. RadGrid is retrieving the records at initial load, without the user having entered any filter criteria. I need the RadGrid to be blank prior to the user entering the filter criteria.
2. Upon entering the filter criteria, RadGrid is retrieving all the records form the DB (around 300,000), and then filtering them, rather than the other way around.
3. I would like the "onitemcommand="CustomMatches_TelerikRadGrid3_ItemCommand"" event to be fired before the "CustomMatches_TelerikRadGrid3_NeedDataSource" event. Is there a way to switch their order of execution?
The relevant code segments are as follows:
protected
void
CustomMatches_TelerikRadGrid3_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
// get the parent customer for whom the custom matches are being searched
GridDataItem parentItem_UnMatchedCustomer_TelerikRADGrid2Row = ((sender
as
RadGrid).NamingContainer
as
GridNestedViewItem).ParentItem
as
GridDataItem;
string
unMatched_MemberID = parentItem_UnMatchedCustomer_TelerikRADGrid2Row.GetDataKeyValue(
"MemberID"
).ToString();
string
unMatched_CustomerID = parentItem_UnMatchedCustomer_TelerikRADGrid2Row.GetDataKeyValue(
"CustomerID"
).ToString();
List<MatchToMember> UnMatchedDetails_PotentialMatches_BindToTelerikRadGrid =
new
List<MatchToMember>();
isCustomSearchExpanded = (sender
as
RadGrid).Visible;
if
(unMatched_CustomerID == customFilterRow_CustomerID)
{
if
(isCustomSearchExpanded && isRadGrid3CurrentlyCustomFiltering)
{
using
(appsEntities appsContext =
new
appsEntities())
{
UnMatchedDetails_PotentialMatches_BindToTelerikRadGrid = appsContext.membership_all
.Select(y =>
new
MatchToMember()
{
CustomerID = unMatched_CustomerID,
MemberDetails = y
})
.Distinct()
.ToList();
}
}
}
if
(UnMatchedDetails_PotentialMatches_BindToTelerikRadGrid !=
null
)
{
(sender
as
RadGrid).DataSource = UnMatchedDetails_PotentialMatches_BindToTelerikRadGrid;
}
//include this if statement so that if the custom search does not return a match, the expanded child datagrid shows "No Records to Display", rather than a blank line.
else
{
(sender
as
RadGrid).DataSource =
new
List<MatchToMember>();
}
//}
wasRadGrid3BindAttempted =
true
;
}
The line
"tempRadGrid3.Rebind();
" in the following code does not cause the "CustomMatches_TelerikRadGrid3_NeedDataSource
" event from above to be called, as I was hoping that it would.protected
void
CustomMatches_TelerikRadGrid3_ItemCommand(
object
sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.FilterCommandName)
{
// get the parent customer for whom the potential matches are being searched
GridDataItem parentItem_UnMatchedCustomer_TelerikRADGrid1Row = ((sender
as
RadGrid).NamingContainer
as
GridNestedViewItem).ParentItem
as
GridDataItem;
string
unMatched_MemberID = parentItem_UnMatchedCustomer_TelerikRADGrid1Row.GetDataKeyValue(
"MemberID"
).ToString();
string
unMatched_CustomerID = parentItem_UnMatchedCustomer_TelerikRADGrid1Row.GetDataKeyValue(
"CustomerID"
).ToString();
isRadGrid3CurrentlyCustomFiltering =
true
;
customFilterRow_CustomerID = unMatched_CustomerID;
if
(wasRadGrid3BindAttempted)
{
RadGrid tempRadGrid3 = sender
as
RadGrid;
tempRadGrid3.Rebind();
}
}
}
These variables are defined at the top of the code behind page, right above the "Page_Load" method, in order to keep track of the state of different events/objects, between the different functions on the page.
// Hack3: keep track of whether or not the Custom Search is expanded
bool
isCustomSearchExpanded =
false
;
// Hack 4: determine if currently custom searching for State Bar member
bool
isRadGrid3CurrentlyCustomFiltering =
false
;
// Hack 5: keep track of which row of Customer is expanded for custom search
string
customFilterRow_CustomerID;
// Hack 6:
bool
wasRadGrid3BindAttempted;
Is this enough information to help answer my questions? I can provide additional information if need be.
Thanks!