How to determine currently sorted header column in data grid? - apache-flex

I want to know which header the user clicked on to give the currently sorted view.
Is there an API in flex framework that I can use to achieve this? Hopefully I can get back a column index so I know how it is currently sorted.
Thanks,
Mike

The mx.controls.DataGrid has a property named columns. Each column in this collection is an object of type mx.controls.dataGridClasses.DataGridColumn with a boolean property named sortDescending.
Otherwise, you can receive and handle the DataGrid event headerRelease. This event is transmitted when the user releases the mouse button on a column header, causing the column to become sorted.

Related

Displaying List<string> in a grid column

Is there a way that one can use a control in a gridview that displays a simple List<string> in a dropdown just like SearchLookUp or even a simple Dropdown? The tricky part is that this List<string> is not predefined, it can change for each row in the grid.
For example if I have a grid with each row representing an ECU of a vehicle. This object contains a List<string> representing SoftwareVersion allowed for the ECU, among st which the user can then select one that is in accordance to their needs. Since each ECU can have different software versions, I cannot assign a pre-defined data source and bind it to SearchLookUpEdit . So I am searching for a solution to make it happen.
Any suggestions will be highly appreciated.
You can use a RepositoryItemComboBox control for this. In order to have a different list of ECU items in each row, handle the GridView's CustomRowCellEdit event and assign the editor at runtime.
You can add all of the strings in your List to the editor's Items collection and additionally set the TextEditStyle property to TextEditStyles.DisableTextEditor to prevent the end-user from typing in their own values.

first value should be selected when loading the data in ComboBox

I had a comboBox and loading the datadynamically from the server. i need to display the first value in comboBox as a selected value and based on the value data should be populated on the grid. Please send me a sample example on the same if nay one knows.
thanks,
Ravi
You can select the first value by setting: selectedIndex=0 or set the selectedItemproperty.
But you should make sure that there is an item which you can select. This could be for example done in the setter of the dataProvider.
Another way to make sure that you have data is add a ChangeWatcher to the dataProvider, so that you will be notified when new data is bound. Then you can simply traverse the data and select whichever one you want, in your case selectedIndex=0;

Edit first column of GridView

I've got very dynamic GridView and I need to allow to user to edit first column of it. After he edit first column of grid it must be updated on DataBase.
Is there any ways to handle it ?
My only idea is to put some changeable element to first cell of each Row so it must be able to set / get my values for each row but can't find yet any examples of it ...
Additional info :
GridView takes data from Object data source and all columns are dynamic (yes, maybe except first, but I add it in dynamic way) and load complete DataTable... \
Currently Using jQuery+Ajax methode on dynamic button but can't disable button's PostBack so with a PostBack it just disappears and dont make the event it must to make...
Since you have dymanic columns, for each column, specify the read-only property (If a column is read-only, it may only be looked at, and not edited when in the GridView's Edit-Mode).
So, the first column of would be readonly="false" (or omit it entirely) and the other columns read-only="true".

Get Changed Rows of GridView ASP.Net

How Can I find all the rows that has been changed in gridview. I can not use Ajax in any form
First get the contents of your grid before it was changed (such as caching the results of the original gridview datasource binding). Then go through the dataset/datatable/however you want to store it, and compare the contents with the current rows of the gridview.
There's no real efficient way to do this, no method like GridView.GetAllChangedRows(). So, what you might do instead is keep a behind the scenes List that you add to each time a row is modified (use the RowUpdated method), then clear this list when needed.
It depends upon how many columns you want to edit in a row.
If you have only one editable column in a row then you can associate a javascript method with that control which you want to modify and in that method you can get a rowid which you can save in another hidden field and in server side you can get all rows whose ids are stored in hidden field.
If you have whole row editable in that case the best approach I think you should save the original data source somewhere and also set a javascript method with rowclick event to get rowid which user selects. Then when user clicks on submit button get all rows whose row ids are stored in hidden field then compare those with same rowid in datasource. This is the best approach from my point of you.
Let me give you an example, suppose there are 1000 rows in a grid and user clicks on only 180 rows. In that case we will compare only 180 rows and wont compare rest of the rows.
Please let me know if somebody has better idea then this.

"freeze" one column in flex datagrid

I'm using a datagrid to display a column of date ranges and several columns of data. I'd like to make the first column (the date ranges) fixed; i.e. that column stays in place when the user scrolls the other columns. That way, the dates column will always be visible as the user scrolls through many data columns. I don't see a datagrid property for this; anyone have a solution? TIA
lockedColumnCount (and lockedRowCount) is more than likely what you are looking for.
http://livedocs.adobe.com/flex/3/langref/index.html
The reason you probably didn't see it is because it is part of the DataGridBase and not part of the DataGrid class itself.
use locked column count property
lockedColumnCount=”1″ height=”96″ horizontalScrollPolicy=”on”
verticalScrollPolicy=”on” width=”397″>

Resources