Hello all,
I managed to get wort working but now I am having trouble with Filtering as well. I have a grid that I am binding to an Entity from Entity Framework. I've tried several different methods including the basic filtering and now I am trying to to do custom filtering. No matter what I try I keep getting "no records" or blank lines. Attached is my code. I even tried filtering the entity to create a filtered version of that but even though when I step through the code and I know there are 2 records that match the grid loads saying "no records found".
I also attached a before and after image so you can see what I am seeing. Any assistance would be greatly appreciated.
Thanks,
Rhonda
I managed to get wort working but now I am having trouble with Filtering as well. I have a grid that I am binding to an Entity from Entity Framework. I've tried several different methods including the basic filtering and now I am trying to to do custom filtering. No matter what I try I keep getting "no records" or blank lines. Attached is my code. I even tried filtering the entity to create a filtered version of that but even though when I step through the code and I know there are 2 records that match the grid loads saying "no records found".
I also attached a before and after image so you can see what I am seeing. Any assistance would be greatly appreciated.
Thanks,
Rhonda
<
telerik:RadGrid
ID
=
"ChecklistsGrid"
runat
=
"server"
Skin
=
"WF"
EnableLinqExpressions
=
"false"
EnableEmbeddedSkins
=
"false"
AllowSorting
=
"true"
OnSortCommand
=
"ChecklistsGrid_SortCommand"
OnItemDataBound
=
"ChecklistsGrid_ItemDataBound"
OnItemCommand
=
"ChecklistsGrid_ItemCommand"
AllowFilteringByColumn
=
"True"
>
<
MasterTableView
Width
=
"100%"
CommandItemDisplay
=
"Bottom"
AutoGenerateColumns
=
"false"
EnableViewState
=
"false"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Application.Name"
HeaderText
=
"Application (WAM Id)"
UniqueName
=
"Name"
FilterListOptions
=
"VaryByDataTypeAllowCustom"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"StartsWith"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"LOB"
HeaderText
=
"LOB"
UniqueName
=
"LOB"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"projectPackages"
HeaderText
=
"Project/Package"
UniqueName
=
"projectPackages"
AllowSorting
=
"false"
AllowFiltering
=
"false"
FilterControlWidth
=
"0"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Status"
HeaderText
=
"Checklist Status"
UniqueName
=
"Status"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"StartsWith"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"dateToYellow"
HeaderText
=
"Date to Yellow"
UniqueName
=
"dateToYellow"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"StartsWith"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"dateToRed"
HeaderText
=
"Date to Red"
UniqueName
=
"dateToRed"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"StartsWith"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FirstConfirmedInstallDate"
HeaderText
=
"Install Date"
UniqueName
=
"installDate"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"StartsWith"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Manager.Name"
HeaderText
=
"Application Manager"
UniqueName
=
"Manager"
></
telerik:GridBoundColumn
>
<
telerik:GridHyperLinkColumn
HeaderText
=
"Open Checklists"
DataTextField
=
"Application.Name"
ItemStyle-HorizontalAlign
=
"Left"
AllowFiltering
=
"false"
UniqueName
=
"OpenChecklist"
HeaderStyle-Font-Bold
=
"false"
HeaderStyle-Wrap
=
"false"
DataNavigateUrlFields
=
"Id"
DataNavigateUrlFormatString
=
"ChecklistPage.aspx?Id={0}"
HeaderStyle-Width
=
"150px"
></
telerik:GridHyperLinkColumn
>
</
Columns
>
</
MasterTableView
>
<
HeaderStyle
BackColor
=
"#666666"
Font-Names
=
"verdana, arial"
Font-Size
=
"Small"
Height
=
"20px"
/>
</
telerik:RadGrid
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
GetCheckListData();
PopulateChecklistGrid();
}
}
public
void
GetCheckListData()
{
checklists = BusinessUtility.GetChecklists(
"0"
);
}
public
void
PopulateChecklistGrid()
{
ChecklistsGrid.DataSource = checklists;
ChecklistsGrid.DataBind();
}
protected
void
ChecklistsGrid_ItemCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.FilterCommandName)
{
Pair filterPair = (Pair)e.CommandArgument;
string
filterPattern = ((TextBox)(e.Item
as
GridFilteringItem)[filterPair.Second.ToString()].Controls[0]).Text;
e.Canceled =
true
;
string
newFilter =
"(["
+ filterPair.Second +
"] >='"
+ filterPattern +
"')"
;
if
(ChecklistsGrid.MasterTableView.FilterExpression ==
""
)
{
ChecklistsGrid.MasterTableView.FilterExpression = newFilter;
}
else
{
ChecklistsGrid.MasterTableView.FilterExpression =
"(("
+ ChecklistsGrid.MasterTableView.FilterExpression +
") AND ("
+ newFilter +
"))"
;
}
ChecklistsGrid.Rebind();
//GetCheckListData();
//List<Entities.Checklist> filteredChecklist = checklists.Where(x => x.Application.Name.ToUpper().StartsWith(filterPattern.ToUpper())).ToList();
//ChecklistsGrid.DataSource = filteredChecklist;
//ChecklistsGrid.DataBind();
}
}
protected
void
ChecklistsGrid_SortCommand(
object
source, GridSortCommandEventArgs e)
{
GridSortExpression sortExpression =
new
GridSortExpression();
switch
(e.OldSortOrder)
{
case
GridSortOrder.None:
sortExpression.FieldName = e.SortExpression;
sortExpression.SortOrder = GridSortOrder.Descending;
e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpression);
break
;
case
GridSortOrder.Ascending:
sortExpression.FieldName = e.SortExpression;
sortExpression.SortOrder = DelegateGrid.MasterTableView.AllowNaturalSort ? GridSortOrder.None : GridSortOrder.Descending;
e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpression);
break
;
case
GridSortOrder.Descending:
sortExpression.FieldName = e.SortExpression;
sortExpression.SortOrder = GridSortOrder.Ascending;
e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpression);
break
;
}
e.Canceled =
true
;
GetCheckListData();
PopulateChecklistGrid();
}
protected
void
ChecklistsGrid_ItemDataBound(
object
sender, GridItemEventArgs e)
{
DateTime currentDate = DateTime.Now;
if
(e.Item
is
GridCommandItem)
{
GridCommandItem cmditm = (GridCommandItem)e.Item;
cmditm.Visible =
false
;
//hide add new button
cmditm.FindControl(
"InitInsertButton"
).Visible =
false
;
//hide the text
cmditm.FindControl(
"AddNewRecordButton"
).Visible =
false
;
//hide the image
//hide Refresh button
cmditm.FindControl(
"RefreshButton"
).Visible =
false
;
//hide the text
cmditm.FindControl(
"RebindGridButton"
).Visible =
false
;
//hide the image
}
if
(Role ==
"AM"
)
{
ChecklistsGrid.MasterTableView.Columns.FindByUniqueName(
"LOB"
).Display =
false
;
ChecklistsGrid.MasterTableView.Columns.FindByUniqueName(
"Manager"
).Display =
false
;
}
if
(Role ==
"WRM"
)
{
ChecklistsGrid.MasterTableView.Columns.FindByUniqueName(
"LOB"
).Display =
false
;
}
}