Same asp:GridView in different ajaxToolkit:TabPanel - c#

I have to filter GridView data based on the Tab Panel selected,
Here is the scenario:
I have the following tabs
All | Tab A | Tab B | Tab C
When I click on "All" tab, I get 10 records and my GridView contains 10 records,
But when I click on Tab A, my GridView need to filter and show 5 records
Right now, I am using the separate GridView for each tab and binding to same DataSourceID.
And using OnActiveTabChanged event to filter the data, but this is invoking underlying method to-execute 4 times (because of 4 tab panels), no problem with the user experience but
there is performance issue...
I am trying to see, if I can use the :
Same GrigView in all the Tab Panels for this type of scenario
Any help is much appreciate, thanks!!

If you want to use a single GridView on all tabs, try invoking the underlying method (that populates the GridView) in OnPreRender instead of OnActiveTabChanged. Make it conditional on which tab is active, and filter accordingly.

You can use the RowFilter property on a DataView and have each tab apply the one you need.
ie DataView1.RowFilter = "Column='ColumnValue'" then set the datasource/databind.

Related

Filter a Kendo UI MVC Grid using checked items in a checkbox column

I have a Kendo UI MVC Grid where I'd like to add a special checkbox column.
This column will not be bound to a model but will be used like a sort of filter.
The idea is that users can check some rows and then click a button (for instance the filter icon in the column header). When clicked, the grid should collapse to the selected rows. The way I see it, it is an extra filter, but not the usual way.
The way my users will work with it would be about as follows:
They select a row and play the attached sound file for that row.
If the row holds an interesting sound file, they may check the checkbox and move to a new row -> 1.
After the selection with checkboxes is made, they will click on the checkbox column filter icon.
The selection will then collapse to the rows that were selected.
After this, the collapsed grid may be exported to excel, pdf or whatever…
A multi select grid is not an option as well as a checkboxed column filter because the selection is not instant, but a process over time.
I cannot find how I would make #4 work. Any suggestions? I don't need a complete solution, ideas are welcome.
The best way is to add boolean 'util' property to your model and bind it to a checkbox column. Once your checkbox column will be bound, your button can execute:
dataSource.filter({ field:"Field", operator: "eq", value: true });
As far I know - there is no build kendo way to manage filtering unbounded columns.

Allowing user to change column order of the datagrid view

I am using Win forms and have a databound DataGridView which has around 31 columns.
AllowUserToOrderColumn is set to true. But since the number of column is 31 its quite difficult for the user to move columns from one end to another.
so I want to create a form which will display all the columns of the datagridview and with the click of up down button allow them to change the order.
I have named my textBox(readonly) from textbox0 to textbox30.
Is there any way to display the column order in text boxes.
Like when we click EditColumns in the designer view.
Certainly:
Look at the DisplayIndex of the columns -> http://msdn.microsoft.com/en-us/library/wkfe535h.aspx
With this, you should be able to read them and change them by code.

Inserting new row in gridview using an external Add button and a list as data source

I have a grid with three columns, two of which contain drop-downs, all of them getting filled from a web service result set. Now I want to allow the functionality of adding a new record in the grid by clicking an Add button present outside the gridview.
Whenever the user clicks the Add button, a new record should be created in the grid with value list filled in the drop-downs with the available options.
What is the best possible way to achieve this considering extensibility in mind.
Thanks a lot!
P.S. The data source set for the grid is a list.
Add a blank item to the list, and rebind with this new list and dummy item. That's typically one way to do it, or store the insert form in the footer of the columns. I've used that approach.

How to persist/store values at runtime

I have a scenario which is as follows:-
A form containing 2 grids. The grid on the left contains a list of groups. When a group is selected the grid on the right populates with another list with check boxes.
I would like to be able to select group A and select some random check boxes and then switch to group B and select some other check boxes. However when I select group A again I would like to be able to restore the previously selected check boxes.
This would allow me to preload the settings from the database and also update the changes in one go rather than expecting the user to select apply after the changes for each group.
I'm unsure of the best way to approach this problem. Any feedback is appreciated.
Thanks
Sean.
I've done something like this using DataTables and DataViews to implement client-side filtering.
You have a dataTable with the tickboxes that contains all groups of data.
Then when you click grid 1, you update the DataSOurce of the grid to a new DataView(DataTable,"GroupID=1")
,"",CurrentRows) (i.e. Sets the filter proprety of the DataView to filter on the selected group
THen when you're done, the DataTable has all the tick boxes you just saev the DataTable to the database.
Hope that makes sense.
I'd start with coming up with a database table to store your data - let's say MyTable(UserId, GroupId, ItemId, Selected). When the app starts I'd read the data from the table based on the UserId. I'd process this data into a couple of collections that I could associated with the grids - one having unique groups, the other items associated with a group and the selection status. Set up some event handlers to keep the collections in sync with the user input. Implement some save routine upon hitting a button or form closing and you should be good !

How to bind the gridview to treeview ,like tree structure hold the gridview data

How to bind the gridview control to treeview , when user click for the + symbol the gridview has to display.. like tree structure hold the gridview data
Thank You
A treeview holds text natively. It is not designed to hold object data in the fashion you're looking for. To achieve this effect you might be better served by nesting a gridview in a gridview with the plus symbol being in the left column as a link/imagebutton and the title or caption in the right column. When the button is clicked you can enter "edit" mode to bring up the edit template, and inside that template can be a separate gridview control that would be bound to the specific data in question. Then click the linkbutton again (which would have been changed to a minus I assume), you could exit edit mode and return to normal. The disadvantage would be that only one row would be able to be open at a time, but that could be worked around by using the regular item template and using viewstate properties to manage row states.

Categories