I have a grid and I will like to filter all the rows of the grid based on one or more columns.For example the data in the grid displays a list of employees. the employees belong to a department.I would like to filter by that column so that I can programmatically filter out rows based on the current user's department.
If for example the current logged-in user is in the Human Resources department, then the grid should only display employees that belong to the same department.
I would like to know also whether this functionality is available for the UltraCombo as well. (Displaying only the employees that belong at the specified department)
Note: I am using Stored Procedures to get the data, but I don't want to apply any filtering at that level. I want all rows returned and then I want to filter out rows programmatically.
Regards,
Nicolas
Hi Nicloas,
Yes, you would use the ColumnFilters collection, either on the Rows collection of the Band (depending on the RowFilterMode property) for the this.
Hi,
Is it possible to post some sample code?
Did anyone ever answer the last question? I'm trying to get something very similar to work and see a lot of people talking about it, but no definite answers or code samples.
There are a couple of ways to do this.
Once way would be to use the ColumnFilters collection on the Band. You could add a filter into the Combo to filter out whatever rows you want.
Another option would be to handle the InitializeRow event of the second combo and examine the values in the row. Then you could set the Hidden property on the row to true or false, depending on the Value of the first combo.
Would anyone have any sample code to do the above request
I have a similar reques.The value member of the first combobox is the id and i have a hidden column in the second combo box for which holds that id as a foreign key. I am currently trying to find a way to find the rows that do not have a matching foreign key and hide them but I am new to infragistics. Any help here please?
You mean like this?
Creating a dropdown list in a grid cell whose list values are dependent on another cell - Windows Forms - Infragistics Community
Hey Guys,
Since we on the topic of filtering a grid. Lets say we have a grid with about 100 rows of data, and you filter the data to the point that only 30 records are left in the grid. if i should save the data, is it that only the 30 visible rows will be saved or will the other 70 records will also be saved. in other words, how can i ensure that only the visible records are saved?
Thanks in advance
fifi5 said: Hey Guys, Since we on the topic of filtering a grid. Lets say we have a grid with about 100 rows of data, and you filter the data to the point that only 30 records are left in the grid. if i should save the data, is it that only the 30 visible rows will be saved or will the other 70 records will also be saved. in other words, how can i ensure that only the visible records are saved? Thanks in advance
What do you mean by save? Are you saving to a database, a report, an external file, etc?
Yeah, it really depends on what kind of save you are talking about here.
Are you referring to saving the grid data to it's DataSource? Or saving the DataSource data to the back end?
If it's the former, then the grid will typically update the data source any time a row loses focus. This is based on the UpdateMode property, though, so you have some options there.
For the latter, the grid has no part in updating the back end. That's between the DataSource and whatever back end you are using (if any).
Hi Mike, let me explain further. I have a ultragrid that i populate with data. let us say the initial record count is 70. I filter the rid to the effect that only 30 records remain (are visible). What i should also mention is that an untyped dataset is binded to the grid. Not an ultradataset, but a regular dataset. I then do the following
string xmlstr = dsData.GetXML();
what is does is give me the xml format for the dataset, which i pass directly into my stored procedure for processing.
This is the question. How to i ensue that only the visible 30 records are sent to my SP?
Please help. Thanks
Filtering in the grid has no effect on the data source to which the grid is bound. So you cannot do this by filtering the grid.
I think the DataSet/DataTable has filtering capabilities, but I've never actually used them myself. You probably have to create a DataView. You would really need to check with Microsoft documentation or support for help with that, though. As I said, I never used it myself.
Another possibility is - you could loop through the rows in the grid and check the HiddenResolved property on the row. That will tell you if the row is visible to the user or hidden for any reason. Then you could get the ListObject property of the rows that are visible and put those rows into some sort of collection or list and do whatever you want with them. I don't know what your GetXML method does, but if it can operate on a list of rows instead of a DataSet, that might work for you.