In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Xiaobian to share with you the jQuery UI component sample analysis, I believe most people still do not know how, so share this article for everyone's reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
Many customers are faced with scenarios where they want to preserve the end user's preference state after sorting or filtering has been applied. Often, when we apply sorting or filtering after selecting any row, selection state is lost after the postback. This blog post will discuss how we can do things to keep selection after sorting and filtering.
Step 1: Bind GridView to a data table
First, we need to bind gridview to a data table, such as the Categories table from the Northwind database. Since we are using server-side selection, we need to set the AutoGenerateSelectButton property to "True" and then set the "ClientSelectionMode" property to "None." Otherwise, we have both client and server options.
In addition, we need to set AllowSorting and ShowFilter properties to "True" to allow sorting or filtering on gridview. Here is the source code for the.aspx page:
Step 2: Save Selected Rows
We need to save the selected row's data keys in a ViewState object so that we can use it to set the selection again. So we need to handle the SelectedIndexChanged event. The code snippet used in this event is as follows
Step 3: Reset the selected row index
We need to reset gridview's SelectedIndex property before sorting or filtering is complete and the selection action is performed again. This can be done in the Sorting or Filtering event with the following code snippet:
Protected Sub C1GridView1_Sorting (sender As Object, e As C1.Web.Wijmo.Controls.C1GridView.C1GridViewSortEventArgs) Handles C1GridView1.Sorting 'Reset Select Index C1GridView1.SelectedIndex = -1 End Sub Protected Sub C1GridView1_Filtering (sender As Object, e As C1.Web.Wijmo.Controls.C1GridView.C1GridViewFilterEventArgs) Handles C1GridView1.Filtering 'Reset Selection Index C1GridView1.SelectedIndex = -1 End Sub
Step 4: Reselect the row
Since gridview is rebound on postback (due to sorting or filtering), we need to handle the DataBound event to reset the selection. Here, we should check whether the originally selected row is visible and then reselect it via the ViewState object. The code snippet looks like this:
Protected Sub C1GridView1_DataBound(sender As Object, e As System.EventArgs) Handles C1GridView1.DataBound Dim Row As C1GridViewRow Dim SelectedValue As String = ViewState("SelectedValue") If SelectedValue Is Nothing Then Return End If 'Check if the selected row is visible and reselect it. For Each Row In C1GridView1.Rows Dim KeyValue As String = C1GridView1.DataKeys(Row.RowIndex).Value If (KeyValue = SelectedValue) Then C1GridView1.SelectedIndex = Row.RowIndex End If Next End Sub
The above is "jQuery UI widget sample analysis" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.