DevExpress Datagrid sorting - sorting

In a DexEpress ASPxGridView I have a column that contains voltage. The original values look like 200, 1000, 120 but I am applying a scaling that transforms the values into 200 V, 1 kV and 120 V.
How do I sort the column based on the original values and not the string values?
(In a .Net datagrid I had 2 columns: one with the original data (hidden) and one with the transformed data and I used the original data column to sort the rows. Is there something similar here?)

Set the column's Settings.SortMode to the Value property. This should force the grid sort value in this column the way you need it.

I had a problem with sorting. I sorted a column by using
this.gvRuleDetail.SortInfo.AddRange(new DevExpress.XtraGrid.Columns.GridColumnSortInfo[] {
new DevExpress.XtraGrid.Columns.GridColumnSortInfo(this.gcRuleOrder, DevExpress.Data.ColumnSortOrder.Ascending)});
but then I realized that column shown sorted but actual data I mean first loaded data is not sorted. To solve this you also have to update first data:
this.gvRuleDetail.BeginSort();
this.gvRuleDetail.SortInfo.AddRange(new DevExpress.XtraGrid.Columns.GridColumnSortInfo[] {
new DevExpress.XtraGrid.Columns.GridColumnSortInfo(this.gcRuleOrder, DevExpress.Data.ColumnSortOrder.Ascending)});
this.gvRuleDetail.EndSort();
for devexpress problems, I recommend devexpress documentation here

Related

Google script - Sheets - sort - how to avoid sorting the first row?

A stupid thing that got me cracking my head. I'm sure you'll laugh, but how do I
sort a sheet without including the first row in the sort?
Here's my code:
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("test1");
spreadsheet.sort(4); // or spreadsheet.sort(4,false); or spreadsheet.sort(4,true);
This sorts by column D, but it also sorts the first row. Column D contains only text.
Funny thing is that if you sort a column which has just numbers/dates, it works and it indeed avoids sorting the first row.
So, how can I sort a column with text and avoid sorting the first row?
I know that I can set a range start at A2 until the last column but this seems "messy". Something like this
spreadsheet.getRange('A2:AI').sort({column: 4, ascending: true});
Thanks
What about this solution:
Freeze the header row and then perform the sorting operation.
In this way it's easy and readable to select the row that will contain the headers of your spreadsheet and you can apply all the sorting operations with a cleaner syntax:
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("test1");
spreadsheet.setFrozenRows(1);
spreadsheet.sort(4);
Reference
.setFrozenRows()
You'll probably find this "messy" too but maybe you could save the first item, sort your column and insert back the first item ?
About the working sort of dates/numbers, maybe the sheet detects that the first cell is the only different one (not a number or a date) and then don't sort it ?

Handsontable: How to pass id to a cell?

I'm using Handsontable and was able to fill a data grid with 16 rows and 9 columns retrieved from a database. Each cell represents a value from a table with a many to many relation. When saving the data-grid, an array is passed to view. I want to clearly identify each cell with the id provided from the table. Is this possible? I read about the setCellMeta(), but don't know how to apply this...
What you can do is iterate all cells and set metadata for each cell (rows and columns) with the value you need.
myhot.setCellMeta(0,0,'Id',1);// where parameters are: row, col,propertyName, value.
later you can do the following to read :
myhot.getCellMeta(0,0) // rown, col
I hope it helps

ExtJS 6 Sort grid Panel groupings by the summary rows

My purpose consist in to do sort ascending / descending the groups by its summary instead of their raw data as usual.
There is another similar issue about this, but the solution that was given, doesn't fit what I need.
Using that same fiddle as an example: https://fiddle.sencha.com/#fiddle/1im3, how can I do sort by the summary of 'Estimate' column, rearranging the grouped data by the 'Project' column?

Sorting on hidden data

Is it possible to have data in a Handsontable sorted by a field which is not displayed? I have a grid of data which I would like to display that contains a column called "sortOrder", but I don't want to display this.
The sorting needs to be done client side because events are coming in over web sockets and need to be reflected in the table.
If you're not showing the column then I assume you're not expecting the user to be able to manually sort by this hidden column. Therefore, why don't you simply sort your data array with native JS? At any point during execution you could have a function which sorts by this hidden column and then just don't render this in your Handson definition.
So yes, the answer is it is possible. The not showing of a column is as simple as defining the columns option and not including a column for this hidden value.

Slickgrid: array scheme inconsistent when data exceeds initial row count

I initialize an editable Slickgrid with n rows. A user keys or pastes >n rows of data. The grid adds rows to hold the extra data, but when I then grid.getData() the resulting array has a different format for rows >n. For example, when n=2 it looks like this
[["A","I","X"],
["B","J","Y"],
{"0":"C","1":"K","2":"Z"}]
I need this array to be uniformly constructed. I tried this but without effect:
grid.updateRowCount();
grid.render();
thatdata=grid.getData();
Hopefully I'm missing something simple in the docs--any help appreciated!
Edit: I should have mentioned I'm using the Celebio/Nereo labs fork, so this isn't purely a Slickgrid question.
SlickGrid does not add the data to the array for you. You do that by subscribing to onAddNewRow and providing the implementation to add a new item to the array, so it's your code that adds the data in the wrong format.

Resources