user will select date and other option (by radcombobbox) and then click "Search" button to show the result in radgrid.but user input text for filter or click the header to sort, the grid will disappear.
user need to click the "Search" button again to show the result. how can i solve it ? thanks.
the code as follows:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="false" PageSize="300" AllowMultiRowSelection="true"
CssClass="radgrid" AllowFilteringByColumn="true" AutoGenerateColumns="false"
GridLines="None" CellSpacing="0" Visible="true" EnableLinqExpressions="false">
<ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="false">
<Selecting AllowRowSelect="True" />
</ClientSettings>
<MasterTableView DataKeyNames="id">
<Columns>
<telerik:GridTemplateColumn UniqueName="RowNo" HeaderText="No." AllowFiltering="false">
<ItemTemplate>
<%# (Container.ItemIndex+1).ToString() %>
</ItemTemplate>
<HeaderStyle Width="30px" />
</telerik:GridTemplateColumn>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" Visible="true" >
</telerik:GridClientSelectColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderStyle-Width="50" ItemStyle-ForeColor="Blue" Visible="true">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="DisplayName" ShowFilterIcon="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
FilterControlAltText="Filter DisplayName column" HeaderText="DisplayName"
SortExpression="DisplayName" UniqueName="DisplayName" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Job_Title" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="true"
FilterControlAltText="Filter Job_Title column" HeaderText="Job_Title"
SortExpression="Job_Title" UniqueName="Job_Title">
</telerik:GridBoundColumn>
XXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXX
</Columns>
</mastertableview>
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
Code behind as follows:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Server.ScriptTimeout = 1200
End Sub
Protected Sub btn_Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Search.Click
LoadSearchResult()
End Sub
Private Sub LoadSearchResult()
Dim dc As New dcDataContext
'get level3 of radcombobox
Dim strCOM_cmb As String = ""
For i = 0 To df_location_lv3.CheckedItems.Count - 1
If df_location_lv3.CheckedItems(i).Checked = True Then
strCOM_cmb += df_location_lv3.CheckedItems(i).Value.ToString & ","
End If
Next
If Left(strCOM_cmb, 1) = "," Then
strCOM_cmb = Right(strCOM_cmb, Len(strCOM_cmb) - 1)
End If
If Right(strCOM_cmb, 1) = "," Then
strCOM_cmb = Left(strCOM_cmb, Len(strCOM_cmb) - 1)
End If
strCOM_cmb = TrimList(strCOM_cmb)
Dim listCOM_cmb = Split(strCOM_cmb, ",")
Dim txt_name_from As String = "A"
Dim txt_name_to As String = "Z"
If txt_displayname_start_from.Text <> String.Empty Then
txt_name_from = txt_displayname_start_from.Text.ToLower.Trim
End If
If txt_displayname_start_to.Text <> String.Empty Then
txt_name_to = txt_displayname_start_to.Text.ToLower.Trim
End If
Dim rec = (From a In dc.TmpDB_LMS _
Where a.EmailDate Is Nothing _
And a.Level2Desc = df_location_lv2.SelectedValue _
And listCOM_cmb.Contains(a.Level3Desc) _
And a.StartDate = CType(df_start_date.SelectedValue, Date) _
And a.DisplayName.ToLower().Substring(0, txt_name_from.Length).CompareTo(txt_name_from.ToLower()) >= 0 AndAlso a.DisplayName.ToLower().Substring(0, txt_name_to.Length).CompareTo(txt_name_to.ToLower()) <= 0 _
Order By a.DisplayName _
).ToList
RadGrid1.DataSource = Nothing
RadGrid1.DataSource = rec
RadGrid1.DataBind()
End Sub
user need to click the "Search" button again to show the result. how can i solve it ? thanks.
the code as follows:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="false" PageSize="300" AllowMultiRowSelection="true"
CssClass="radgrid" AllowFilteringByColumn="true" AutoGenerateColumns="false"
GridLines="None" CellSpacing="0" Visible="true" EnableLinqExpressions="false">
<ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="false">
<Selecting AllowRowSelect="True" />
</ClientSettings>
<MasterTableView DataKeyNames="id">
<Columns>
<telerik:GridTemplateColumn UniqueName="RowNo" HeaderText="No." AllowFiltering="false">
<ItemTemplate>
<%# (Container.ItemIndex+1).ToString() %>
</ItemTemplate>
<HeaderStyle Width="30px" />
</telerik:GridTemplateColumn>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" Visible="true" >
</telerik:GridClientSelectColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderStyle-Width="50" ItemStyle-ForeColor="Blue" Visible="true">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="DisplayName" ShowFilterIcon="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
FilterControlAltText="Filter DisplayName column" HeaderText="DisplayName"
SortExpression="DisplayName" UniqueName="DisplayName" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Job_Title" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="true"
FilterControlAltText="Filter Job_Title column" HeaderText="Job_Title"
SortExpression="Job_Title" UniqueName="Job_Title">
</telerik:GridBoundColumn>
XXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXX
</Columns>
</mastertableview>
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>
Code behind as follows:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Server.ScriptTimeout = 1200
End Sub
Protected Sub btn_Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Search.Click
LoadSearchResult()
End Sub
Private Sub LoadSearchResult()
Dim dc As New dcDataContext
'get level3 of radcombobox
Dim strCOM_cmb As String = ""
For i = 0 To df_location_lv3.CheckedItems.Count - 1
If df_location_lv3.CheckedItems(i).Checked = True Then
strCOM_cmb += df_location_lv3.CheckedItems(i).Value.ToString & ","
End If
Next
If Left(strCOM_cmb, 1) = "," Then
strCOM_cmb = Right(strCOM_cmb, Len(strCOM_cmb) - 1)
End If
If Right(strCOM_cmb, 1) = "," Then
strCOM_cmb = Left(strCOM_cmb, Len(strCOM_cmb) - 1)
End If
strCOM_cmb = TrimList(strCOM_cmb)
Dim listCOM_cmb = Split(strCOM_cmb, ",")
Dim txt_name_from As String = "A"
Dim txt_name_to As String = "Z"
If txt_displayname_start_from.Text <> String.Empty Then
txt_name_from = txt_displayname_start_from.Text.ToLower.Trim
End If
If txt_displayname_start_to.Text <> String.Empty Then
txt_name_to = txt_displayname_start_to.Text.ToLower.Trim
End If
Dim rec = (From a In dc.TmpDB_LMS _
Where a.EmailDate Is Nothing _
And a.Level2Desc = df_location_lv2.SelectedValue _
And listCOM_cmb.Contains(a.Level3Desc) _
And a.StartDate = CType(df_start_date.SelectedValue, Date) _
And a.DisplayName.ToLower().Substring(0, txt_name_from.Length).CompareTo(txt_name_from.ToLower()) >= 0 AndAlso a.DisplayName.ToLower().Substring(0, txt_name_to.Length).CompareTo(txt_name_to.ToLower()) <= 0 _
Order By a.DisplayName _
).ToList
RadGrid1.DataSource = Nothing
RadGrid1.DataSource = rec
RadGrid1.DataBind()
End Sub