I am using AG Grid Enterprise edition with unbalanced groups and I'm looking for a way to sort the rows inside the group always alphabetically, and not by the column sorting applied.
In the example below if the users sort by either sum(Val1) or sum(Val2) ASC/DESC in the state group I want the cities to be sorted alphabetically.
https://plnkr.co/edit/VMNY3wHMZ3DlpcJi?open=app%2Fapp.component.ts
I just took the default example from https://ag-grid.com/angular-data-grid/grouping-unbalanced-groups/ and made the columns sortable.
public defaultColDef: ColDef = {
flex: 1,
minWidth: 150,
resizable: true,
sortable: true
};
Related
In the data I have there are multiple Boolean columns that categorise each row, for example:
Object
Fruit
Yellow
Round
Chair
FALSE
FALSE
FALSE
Banana
TRUE
TRUE
FALSE
Apple
TRUE
FALSE
TRUE
Ball
FALSE
FALSE
TRUE
I am trying to make a KPI chart that would go alongside a table of this data in which it would have 'Fruit', 'Yellow', & 'Round' as categories and a count of how many are true, so that when you click on them it will mark and limit the data in the table. In this example 'Fruit' would have a count value of 2, 'Yellow' 1, and 'Round' 2.
How can I make a single KPI chart look at multiple columns and count their True values? I tried making a second data table to unpivot the columns into rows and have their count, which works, but then I am unsure as to how to make a relation between the two table such that I can mark and limit the original data table?
Please let me know if you require any information. I am using Spotfire 10.10, and this is how the data is presented to me, I cannot change it.
I have a vuetify Data-table with multisort enabled like so:
<v-data-table
ref="insuranceTable"
:headers="headers"
:items="getRows"
:sort-by="['created']"
:sort-desc="[true]"
multi-sort
:search="search"
:items-per-page="10"
>
one of the columns in the table is Insurance Type. this value is fetched by using an index like this {{insuranceType[item.code]}}. The insuranceType array is defined as follows:
insurancetype:[
this.$t('insuranceType.life'),
this.$t('insuranceType.health'),
this.$t('insuranceType.property'),
]
The values are displayed in the data-table without any issue. However, When I try To sort the table by Insurance Type Column, nothing happens. The Sorting works for all other columns. The sorting works for Insurance Type column if I use a non i18n array like this:
insurancetype:['life','health','property']
How can I configure the V-Data-Table so it can be sorted by columns with i18n values?
You can define a custom sorting function for the Insurance Type column in your headers array. I've used this method before to be able to sort some custom string dates formats like this:
headers: [
{
text: 'Created date',
value: 'created_at',
align: 'center',
sort: (a, b) => {
var date1 = a.replace(/(\d+)\/(\d+)\/(\d+)/, '$3/$2/$1')
var date2 = b.replace(/(\d+)\/(\d+)\/(\d+)/, '$3/$2/$1')
return date1 < date2 ? -1 : 1
}
},
...
]
You should be able to add your own logic to be able to sort those. Can you replicate the issue in a codesanbox or codepen?
I have a jqGrid with the grid-level 'sortable' option enabled. This lets me drag columns around to reorder them, which is great. But I want to prevent users from doing this with one specific column, leaving the others unaffected. Is this possible?
I find your question very interesting and so I made the corresponding demo which demonstrate the solution. On the demo is the first column "Date" unsortable.
I recommend you to read two other old answers on the close subject: this and this. My suggesting are based on the same idea.
There are internal jqGrid method sortableColumns which will be used internally if one uses sortable: true option of jqGrid. The sortableColumns method uses jQuery Sortable for the implementation and initializes items options of the grid having id="list" to the value ">th:not(:has(#jqgh_list_cb,#jqgh_list_rn,#jqgh_list_subgrid),:hidden)". It makes the columns "cb", "rn" and "subgrid" unsortable. The columns could be inserted in the grid if you use jqGrid options multiselect: true, rownumbers: true or subGrid: true. In the same way is you have the column with name: "invdate" then the corresponding id of the column element will be jqgh_list_invdate. So one can use the option sortable as the following
sortable: {
options: {
items: ">th:not(:has(#jqgh_list_cb,#jqgh_list_invdate,#jqgh_list_rn,#jqgh_list_subgrid),:hidden)"
}
}
to make the "invdate" column unsortable.
I have a DataGrid, created programmatically and loaded from ItemFileReadStore.
I want the first column of DataGrid always be sorted in descending order and disabled for user for sorting. Any other column should be available for sorting as a secondary sortable.
I don't want to give users such a powerful(complex and confusing) feature, as sorting by multiple columns, because there are too many columns in my grid.
So, it should be one sortable column for user and another one "already sorted unsortable" column in fact.
Does anyone know how can this be achieved?
Thanks.
To sort the first column add "sortInfo:-1" when you created your object.
To allow sorting the grid from any other columns but not the first you need to overwrite the function canSort.
To create you grid should now look like this .
dijit.grid.DataGrid({
canSort: function (sortInfo) {
if (Math.abs(sortInfo) == 1){
return false;
} else {
return this.inherited("canSort", arguments);
}
},
sortInfo: -1, .....
If you need to sort on more as one column you need dojox.grid.enhanced.plugins.NestedSorting.
http://dojotoolkit.org/reference-guide/1.7/dojox/grid/EnhancedGrid/plugins/NestedSorting.html
In a grid with 5 columns, I would like to have the possibility of sorting only for columns 2 and 4.
What is the correct demarch for implement this ?
- declare sortable to true for columns 2 and 4
- what else ?
Default value of sortable property is already true (see here). So you have to include
sortable: false
property in the definition of all columns in colModel with exception columns 2 and 4. If you have many columns, then it would be better to change defaults for colModel items:
cmTemplate: { sortable: false }
After that you should include sortable: true in columns 2 and 4. In the way you can change any other defaults for colModel. See the answer for more details.