This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I have been unable to find a way to display strings in Dgrid. I have no trouble creating the column label in the target with:
const char *programLabels [3] = {"ID", "Delay Value", "Description"} ; // for the Dgrid widget Column Names field;
However, if I use the TI recommended method for binding to a char array for the Dgrid widget Data field (from the wiki on "Binding to an array of C Strings") where I am trying to bind the variable names to the field using:
char = names[] = {"John", "Peter", "Alex"}; // Dgrid Data Values
The Dgid displays a letter J in the first column, an o in the second column and a h in the third column of the table. Obviously not what I need. What am I doing wrong? What is the correct way of getting a string into Dgrid. If this is not possible can someone post the documentation on the gc.dijit.Dgrid widget with a description of any methods for setting and getting data into the grid. This is only useful if I can set string values into the widget.
is there a preprocessing or post processing fix to this problem?
BTW, Dgrid works fine for displaying integer values using a statement like:
int dataValue[3][3] = {{1,2,3}}, {4,5,6},{7,8,9}};
However, I have been unable to coerce it into displaying strings. Any help with a description of the c code for getting a string into the grid would be most appreciated.
Thanks again for your help.
GUI Composer currently does not support binding to two dimensional string arrays.
It is possible to use multiple "GUI Vars" to bind to each of the array's row, which itself is one dimensional string array.
When the value of each of the "GUI Vars" changes, you can make it set the corresponding Grid raw to its value.
Of course this solution assumed that the first dimension of the array does not change.
Regards
Dobrin
Here is an example of binding a two dimensional string array in GUI Composer.
Here is how I declared my two dimensional strings in my C program:
char* twoDimCharArray [2][2] = {{"A0","A1"},{"B0","B1"}};
In GUI Composer
Add a DGrid
Change its id to “mygrid”.
Do not bind the grid to anything, do not change any other property.
Add two GUI Vars: “row0” and “row1”.
Set their data type to “Array”.
Add OnPropertyChange to both GUI Vars: “onRow0PropertyChanged” and “onRow1PropertyChanged”.
Here is the content of app.js. Note that I added two global variables “grid” and “data”.
Before we set the data of the grid we need to set its columns in “ready” callback.
var data = [["",""],["",""]];
var grid;
require(["dojo/ready"], function(ready){
ready(function(){
grid = dijit.byId('mygrid');
grid.set("columns",["X","Y"]);
});
});
function onRow0PropertyChanged( propertyName, newValue, oldValue) {
data[0] = newValue;
grid.set('data',data);
}
function onRow1PropertyChanged( propertyName, newValue, oldValue) {
data[1] = newValue;
grid.set('data',data);
}