Custom Columns in ASP.NET

Does anyone have any suggestions for the best way to allow users to choose which columns appear in the datagrid? I wish they could customize this. It will be stored with the user in the profile and loaded every time the user loads the grid. I was thinking about something with ASP.NET personalization.

+1


source to share


4 answers


There are several options here.

  • Add an "X" image to the header for each column and with a javascript onclick event, make a web method call to remove that column from the user profile which columns to load.

  • You have a customization popup page where a list of all columns will be displayed and the user can add or remove columns from the grid.



There are a few more, but they are less AJAX and more page reloads.

+1


source


I would tend to have a window or window divout for this, showing only unselected margins, with an option to remove on each title. Sorry if this doesn't add much to the Avitus idea, however I suggest a hybrid of the two suggested ideas, i.e. the departure list only contains unselected columns (e.g. in Outlook). The list will have to be based on each popup or each removal / addition.



Also, I suggest that the user have their selection stored on demand to allow experimental selection of columns before they commit this layout next time and minimize storage access.

0


source


You need to store this information in the database. On the admin page, you can specify the column names and check the "Show? []" Checkbox. When they check this, the display, if not, is not shown. In the ASPX page, when you bind to the grid, pull the columns from the database and iterate through the columns property in the DataTable class and check the column name. If that's good, then display it, if not, then don't.

Here are one hundred and one ways that you can implement, really, the choice is up to you.

0


source


My suggestion is to store this information in a database for each user. If they have no preference then show all columns if they will select columns and then save that information so that each visit only shows what they want to see.

To achieve this, loop through the available columns (field names) and dynamically add them to your data grid. You want to do the same in a list control or similar, so that the user can specify what they want to see. When they add the columns you want, you rebuild your grid by showing only those columns. Each time they add or remove columns from the list, you save their settings to the database.

0


source







All Articles