TableViewer update value of column when value in another column has changed - swt

I have a table with 2 columns both are ComboBox columns. When a user selects a value in column 1, I want to update the options available in the ComboBox for column 2.
How do I do this?

Update the values in your data model and then call TableViewer.update(object, null) where object is data model object for the row (that is the value your content provider returns for the row). The update call will cause the TableViewer to ask the content provider for the values for the row again.

Related

How to update rows / set row data in server side row model type in ag grid?

My data model looks like this. Array of objects containing title and created_date.
{
title : String
created_date: Date
}
I have defined a column definition which only renders the title. However, I'd like to sort the rows based on the created_date, without creating a created_date column. There will be an external button detached from the table, which will call the api to get the data. I am using row model type serverSide. I have the sorted data from the backend. I just need to update the data / refresh the data. How can I achieve this ? I have so far tried setRowData(updatedRows). but its giving me an error saying cannot call setRowData unless using normal row model. Is there any way to update my rows in this serverSide row model type settings ?
Calling this.gridApi.setServerSideDatasource(myDataSource); and passing in your dataSource will do the trick. Check here for details

How to access a cell value when the column has been defined with ag-grid expression/value getters?

If the ag-grid column definition has been defined with a value getter or if an expression has been defined for a cell the value gets displayed fine on the grid. However I was not able to find a way to access a value in a given cell if the cell is using cell expression/value getters. Was trying to access the data through api.forEachLeafNode, but it seems even the in memory model does not have this data. The only way I found was to export the data as CSV and then parse it using getDataAsCsv(params).
Is exporting the data the only way to access value of a column in a grid with a value getter?
Why does the In Memory model not have this data to access?
valueGetter is used during the rendering stage, it only computes when needed to render the cell. if the cell is never rendered (eg row is below what is currently visible) then the valueGetter is never executed. the result is never stored in the model, it is only passed to the cellRenderer.
so what you need to do to get the result of valueGetter is use api.getValue(colKey,rowNode)
colKey is the id of your column. this can be the column itself (if you got the column from the grid column api) or the column id. the column id is what you will probably want to use. the column id is assigned to the column in the following order 1) the colDef.colId if exists 2) the colDef.field if exists 3) generated if both colId and field are missing. so if you are using a valueGetter, you are probably not providing a field, so just provide a colId.
rowNode is the row in question. this is what you get when you use api.forEachLeafNode.
the api.getValue() method is pretty recent, i know it's in version 7 - so if missing just make sure you are v7 or above.

SAPUI5 table: get none-displayed values of selected row?

I have a SAPUI5 (OpenUI5) application with a table. This table is bound to a (JSON) model and display the name of the entity and some other attribute - but not the technical key.
The user should have the opportunity to select multiple lines in the table and the application should then be able to get the technical keys of the selected lines (probably using the underlying model).
How would I do such a thing?
Thanks in advance!
The rowSelectionChange event has a rowContext attribute. A better approach would be
rowSelectionChange: function(oEvent) {
console.log(oEvent.getParameters().rowContext.getProperty("your_key"));
}
to obtain the value of your key (or any field in the selected row by adapting the getProperty value accordingly)
when you will select a row in a table, there is a event called "rowSelectionChange". Use this event and getSelectedInedx of row.
Using the index value loop over your json and get values selected row.

Can I add the same DataRow to a DataTable multiple times?

If I have a DataTable and want to create a new row I first call DataTable.NewRow() which returns a DataRow. This row then has the schema of the Table, and I can set the value of each field in the row. At this point does the Table "know" about the Row, or does that only happen after I call DataTable.Rows.Add(DataRow row)?
If I call DataTable.Rows.Add() more then once are duplicate rows created in the data table with duplicate values?
The reason I ask is I'm trying to write a recursive function that will iterate down a tree structure and populate a DataTable with values. So I have situations where rows being created for each child will have columns that have all the same values because they come from the parent.
So my idea was to pass a DataRow with the parent's information to each child. The child would add its information and then add the row to the table. But I'm trying to figure out if I need to call DataTable.NewRow() for each child, or if new rows will be created automatically if I add the same row multiple times.
No, but it's easy to copy a row so you can get what you want (assumes the existing row is in a variable called existingRow):
var newRow = dataTable.NewRow();
newRow.ItemArray = existingRow.ItemArray;
dataTable.Rows.Add(newRow);
Yes, old question. But Michael's answer does work. I needed to add multiple duplicate rows to a DataTable for a scheduling app. With dt.Rows.Add(_Users) I got the error:
This row already belongs to this table
But using this, I could loop through and hold as many positions open for a job as needed Where "Length" is the number of positions to hold open for a job:
int Length = int.Parse(TextBox6.Text.Trim());
for (int i = 0; i < Length; i++)
{
Users.Rows.Add("9999", "Open");
}
Searching Google for this sucks, because most people want to remove duplicate rows in a DataTable, and not add duplicate rows in a DataTable.
No, it will generate an exception of type System.ArgumentException.
i recommend that you put the data in a array and then add the data to data table
e.g.
yourDataTable.Rows.Add(data[0]........);
newdatarow will generate exception error

Axapta: Programmatically switch records in a form

In Dynamics AX 2009, how do you programmatically change to a different record in a form?
My form contains a treeview and a group of bound data fields. When clicking on a record in the tree (the data value for each item in the tree is the RecId of the item I'd like to edit in the form) I'd like to change the form to that record.
I've been using sysSetupForm as an example for working with a tree, but I'm having trouble isolating where the call to change records occurs in their code.
Thanks
Some example:
some_table table;
;
table = some_table:find(recid);
table_ds.findRecord(table); // it's a form datasource method