How to Ignore selected rows when filtering using floating filters in ag-grid? - ag-grid

I'm currently working on a project that uses ag-grid in Angular.
We have a table that displays some sort of data and it's possible to filter this table using some textbox floating filters above the table for every column.
Every row has a checkmark in the beginning that can be used to select this row.
The goal is to figure out a way to not filter out the rows that have been selected by the user. The rest of the rows should get filtered as normal.
Is there an easy way to implement this?
I've been looking trough the documentation and it seems like I will have to write a custom filter component, but I'm not sure where to start. Do filters even have the capability to check if a row is selected or not?

So I figured out an easy way. I created a new simple class:
export class IgnoreSelectionFilter extends TextFilter {
doesFilterPass(params: IDoesFilterPassParams): boolean {
if (params.node.isSelected()) return true;
else return super.doesFilterPass(params);
}
}
I use this class as the "filter" component for every column where this functionality is required. This new class behaves exactly like agTextColumnFilter, but first it will verify if the node is selected or not and ignore it if it's selected.

Related

Syncfusion mvc grid control filtering on hyperlink column

I have just been trying out syncfusion controls for mvc and have come across bit of a hurdle. My problem is that when i use a hyperlink in ej grid column using column template feature the filters just don't work for that column. My current UI is designed that way that i need to render a column value as clickable link and i also need to allow filtering on the basis of value in that column.
To perform actions like filtering, sorting, grouping Fields must be enabled to column. Based on the column value above actions will be performed. To perform filtering in template column,define the Field property to template column.
Refer the below code example
#(Html.EJ().Grid<EmployeeView>("ColumnTemplate")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.ExcelExport);
items.AddTool(ToolBarItems.WordExport);
items.AddTool(ToolBarItems.PdfExport);
}))
.Columns(col =>
{
col.HeaderText("First Name").Field(“FirstName”).Template("#columnTemplate").TextAlign(TextAlign.Center).Width(80).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(100).Add();
col.Field("LastName").HeaderText("Last Name").Width(100).Add();
col.Field("BirthDate").HeaderText("Birth Date").TextAlign(TextAlign.Right).Width(100).Format("{0:MM/dd/yyyy}").Add();
col.Field("Country").Width(100).HeaderText("Country").Add();
})
)
Please get back to us if you have further queries.

Hide column name in personalization dialog box based on condition

I have p13n dialog box in a table, where I am displaying 2 columns coming from the backend.
Now, I want to implement condition in column 2. For example,
if(mainCondition === true)
{
display column2;
}
else
{
hide columns2;
}
The issue here is, these column names are coming from CDS view & with entity set.
I can, of course, hide them completely using the setIgnoreFromPersonalisation method, however, I don't know how can I implement condition on these field's visibility property.
Thanks.
Since the two columns are coming from the backend, you can add Filter to the model to filter out the ones to be hidden.

Grouping expand and collapse in GWT

I have multiple records which needs to be displayed as part of a search. A single result can contain multiple records associated to it. If there are multiple records I need to display the record with (+) and when clicked it further displays the list.
I would like to know what the best way is to implement ( I have checked Custom data grid ex: http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwCustomDataGrid but would like to use UI binder)
Once the user selects a record from the expanded list, how can we load that selected record?
Any pointer are appreciated..! ( Currently on GWT 2.2)
Widget list
Tree or maybe StackPanel seems like it would be useful here.

GWT DataGrid/CellTable: Select all over multiple pages

I´m using GWT 2.4 with a DataGrid and a SimplePager along with a MultiSelectionModel. I want to implement a simple select-all-feature over all pages.
I´m only able to select all visible items on the current page. What is the best way to select all items on all pages?
I know the MultiSelectionModel stores the proxy keys provided by a ProvidesKey object in a HashMap. I think I have to request all proxy objects from server or at least all keys. But actually I don´t want to store information about the ProvidesKey´s getKey()-method on server-side. But I also can not access the MultiSelectionModel´s HashMap of the selected proxies´ keys. This all looks cumbersome, so is there a better way to solve this?
As mentioned in https://developers.google.com/web-toolkit/doc/latest/DevGuideUiCellWidgets#selection, one way to achieve this would be to implement your own SelectionModel (e.g. by extending AbstractSelectionModel or DefaultSelectionModel):
A complex implementation can handle "select all" across multiple pages using a boolean to indicate that everything is selected, and then keep track of negative selections.
Why do you need all keys for select all? When you select some objects from a list, you need to remember which ones are selected, but when you select all objects, you need a single Boolean:
// on click Select All button/checkbox
boolean selectAll = true;
// ask a user what he wants to do
// send a request to server with a parameter selectAll to update/delete all objects
Select all across multiple pages will work only if you are NOT lazy loading. First of all why do you need to select all? If you want to do some actions on all the grid data, you will already have the list and you can perform your actions on the list directly. Nonetheless you can select all the rows of the grid over multiple pages by iterating through the list and using the following API on each item.
public void setSelected(T item, boolean selected);
Note: This will work only if you are NOT lazy loading.

Have a jcombobox filter a jtable

following this tutorial http://www.netbeans.org/kb/docs/java/gui-db-custom.html#enhancements
it shows how to use a textbox to filter out the master table. Could anyone instruct me on how to do a similiar thing but use a dropdown to test against a specific column?
(ie a dropdown of countries, to filter by the country column?
thanks
depending on what the source is for the dropdown.
i assume the dropdown isn't used as part of the Jtable itself, but merely shows a list of unique data coming from one column of data?
in that case, you could get the Jtable's datamodel, and then walk through all the cells in the particular column, putting them in a hashmap with the string as the key. that way you have a list of (unfiltered) unique strings to use as the datamodel for the dropdownbox.
You could attach a model listener to the talbedatamodel to know when your list has to be updated as well.