Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter not working with List and also no second time sorting is working #16

Closed
therabbitears opened this issue Dec 19, 2017 · 25 comments
Closed

Comments

@therabbitears
Copy link

The grid is failed to sort the data if we have sort it using any column it sticks and nothing happens. Filters are not at all working. The list can't sort the data default and so we referred sortable binding list from one of the blog and after that sorting is working but for only once.
Blog for sortable binding list: http://martinwilley.com/net/code/forms/sortablebindinglist.html

@davidegironi
Copy link
Owner

Hello, you have to attache the FilterStringChanged and SortStringChanged events of the grid like exposed on the sample project in order to filter and sort the BindingSource attached to the DataGrid. Hope this helps.

@therabbitears
Copy link
Author

Hello, I am using the whole sample project as It is, just using the List instead of DataSet, nothing else changed, these events are also attached and getting fire appropriately.
I have added the file, you can test replacing the FormMain.cs code file using this one.
FormMain.zip

@davidegironi
Copy link
Owner

Hello, in order to use the Filer and Sort on a binding source you have to use a DataTable.

@zubyk
Copy link

zubyk commented Apr 18, 2018

Hello pals! Thank you for support of my project, you do a great work
I receive many same questions as @baba-banshi asked (where all that people get my email??)

Sorting/Filter with custom Lists or EntityFramework and all other collections not work because DataSource that you want to use must implement IBindingListView interface and have Sort and Filter property.

more details you can search here
https://stackoverflow.com/questions/10074032/datagridview-filter-a-bindingsource-with-a-list-of-object-as-datasource
here https://social.msdn.microsoft.com/Forums/en-US/1cd860c7-9df5-4dec-bce4-f67b3a823079/bindingsource-sort-doesnt-work?forum=adodotnetentityframework
or ask google in same directions

Dear @davidegironi, can you post this answer in the readme.md or any place where peoples can read it? i receive this question very often

Thanks, Zuby

@davidegironi
Copy link
Owner

Hello @zubyk. I've edit the README.md file. Thank you for this project, you made most of the work, and it great!

@Emporea
Copy link

Emporea commented Dec 13, 2020

Is it possible to sort it without knowing the data columns in the first place? If I understand it correctly i need to have BindingSource and declare all datatypes and columns before using a DataTable.

The Problem is that my DataTable isn't same everytime. I have a simple yet customizable program, where the end user can specifiy a sql connection and the sql query on his own. This makes it impossible to declare the columns in the BindingSource.

What can I do?

Edit:
My code snippet that basically is my whole program by now is this:

           `string connString = File.ReadAllText(@"SQLconn.cfg");

            using (SqlConnection conn = new SqlConnection(connString))
            { 
                string query = File.ReadAllText(@"SQLQuery.sql");

                //define the SqlCommand object
                //SqlCommand cmd = new SqlCommand(query, conn);

                //Set the SqlDataAdapter object
                SqlDataAdapter dAdapter = new SqlDataAdapter(query, conn);

                //define dataset
                DataSet ds = new DataSet();
                
                //fill dataset with query results
                dAdapter.Fill(ds);

                //set the DataGridView control's data source/data table
                advancedDataGridView1.DataSource = ds.Tables[0];

                //close connection
                conn.Close();
            }`

@davidegironi
Copy link
Owner

Hello @Emporea , it should work. Take a look at the dentned reports run form, there custom query are executed and loaded to a filtered datagrid view. https://github.com/davidegironi/dentned/blob/master/DentneD/Forms/FormReportsrun.cs

@marceloleandro111
Copy link

I want to use filters and sorts in another language? how can i get it? i updated the new version but in execution time we don't have the option... can i set it in code behind or another configuration?

@davidegironi
Copy link
Owner

Hello @marceloleandro111 , take a look at the sample project. You can "inject" the laguage using the SetTranslations method. Like here:

if (_testtranslationsFromFile)

@marceloleandro111
Copy link

Yeaa! that's it. I found this before....thank you!

@morgp
Copy link

morgp commented Apr 7, 2022

Is it possible to filter data from a button, ie set programmed filtering? If so how?

@davidegironi
Copy link
Owner

davidegironi commented Apr 7, 2022

Take a look here: #79

@JackSadowski
Copy link

Possibly related item: #85

@export-import20219
Copy link

Hii,
I want to change column header icon programatically. is it possible or not?
Thanks in advance.

@barawy
Copy link

barawy commented Nov 27, 2022

can you post example with vb.net and access database
mainly how to use the search bar

@davidegironi
Copy link
Owner

Hello @barawy . This library is mainly written in C#, so for the sample project. Unluckily I've no time to dedicate to sample implementation. Buf if you do this, you can poste your sample link here. It would be helpful maybe for other.

@farshadvl
Copy link

hi. how we can have sum a special column value under that column in this gridview?

@davidegironi
Copy link
Owner

Hello @farshadvl . You can add a custom Row or Colum in your DataTable and use it.

@farshadvl
Copy link

I mean I want to sum filtered column value .how can I do that?

@davidegironi
Copy link
Owner

You have to build a custom function to do that. It's not supported natively

@farshadvl
Copy link

You have to build a custom function to do that. It's not supported natively

I don't have any idea about how to do that . can u please show us how to code that function?

@davidegironi
Copy link
Owner

Unluckily I've no time to implement this... sorry about that. A trick could be add a column at the end of the datatable (ordered as example with an hidden column or updating the sort order string), detecting and changing it whenever the filter change.

@ddveloper1
Copy link

This filter is different from the Excel filter.

If, data = {1,2,3} and I filter only 1
Excel filter shows 1 2 3.
But, this filter shows only 1.
(See attached images)
excel filter
this filter

Can you modify it like an Excel filter?

@davidegironi
Copy link
Owner

Your question is not related to this issue, anyway you could use the SetChecklistTextFilterRemoveNodesOnSearchMode method.
Look at the sample project, columns "decimal".
advancedDataGridView_main.SetChecklistTextFilterRemoveNodesOnSearchMode(advancedDataGridView_main.Columns["decimal"], false);

@ddveloper1
Copy link

I confirmed that it works like Excel filter as you said.
Thank you for your response and for creating such a cool control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests