3.2.0

data from another rows/columns

hi there!
is there any way to get the data from another row/column?
getProperty('item/text') returns the text from the selected item...
but when I click on a row like:
1 text moretext moremoretext
I want to get the moremoretext and print the number 1 (the first column)
does anyone knows a good way to do it?
thanks!
Leandro Koiti
February 10,
Here is the example:

obj.setAction("click", function(src){
        var rowIndex = src.getRowProperty("index")
        var column1_text = this.getDataProperty("text", rowIndex, 1);
        alert(column1_text);
    });


src argument refers to the template which triggers the action,
you can obtain row index through row/index property
then you can retrieve any data item through data/text or data/value properties including rows/columns which are not visible in the grid.
Alex (ActiveWidgets)
February 10,
thank you so much!
you gave the right shot, answered my question, thanks!
by the way... I simply loved this grid, I'm just trying to learn what it can do for real, because it's simply amazing!
leandro koiti oguro
February 12,
How do I combine two columns into one format function in CSV?

I want to split my DATE from my TIME in CSV. When date and time are combined in CSV (yyyy/mm/dd hh:ss), this works:
-------------------------
var string = new Active.Formats.String;
var number = new Active.Formats.Number;
var date = new Active.Formats.Date;
date.setTextFormat('dddd, mmmm d, yyyy, hh:ss');
date.dataToValue = function(v){return(Date.parse(v.substr(5,5) + "/" + v.substr(0,4) + v.substr(10)))};
number.setTextFormat('0');

var table = new Active.Text.Table;
var formats = [date, string, number, string, string];
var _getValue = table.getValue;
table.getValue = function(i, j){return formats[j].dataToValue(_getValue.call(this, i, j));}
var _getText = table.getText;
table.getText = function(i, j){return formats[j].dataToText(_getText.call(this, i, j));}
table.setURL("data/spotGrid.csv");

var obj = new Active.Controls.Grid;
obj.setDataProperty("text", function(i, j){return formats[j].dataToText(myData[i][j])});
obj.setDataProperty("value", function(i, j){return formats[j].dataToValue(myData[i][j])});
var columns = ["Date Time", "Sport", "TV", "Visitor", "Home"];
obj.setColumnProperty("texts", columns);
obj.setModel("data", table);
table.request();
document.write(obj);
---------------------
But when I split them, I don't know how to send (my DATE + my TIME) to the parse function. I changed:
-----------------------
var formats = [date, string, string, number, string, string];
var columns = ["Date", "Time", "Sport", "TV", "Visitor", "Home"];
table.getValue = function(i, j){return formats[j].dataToValue(_getValue.call(this, i, j));}
---------------------------
but "this" needs to be something like mydata [i][j] + " " + mydata[i][j+1]
Thanks for any help.
Reen
May 26,
Hi

I do have a problem with the above code ... I'm trying to get a sum out of my lines whenever I edit a cell.

Here is my code :

function switchToTextMode(){
  var originalVal = template.getItemProperty("text");
  var value = editor.element().value;
  template.setItemProperty("text", value);
  template.refresh();
  if(originalVal != value){
    // value changed, call the callback function
    var row = template.getRowProperty("index");
    var col = template.getColumnProperty("index");
    // ?? something here ?? //
    var totalligne=0;
    var nbcol = template.getColumnProperty("count");
    for(var i=0;i<nbcol-1;i++) {
      totalligne = totalligne + parseInt(template.getDataProperty("value",row,i));
      alert(totalligne);
    }
  }
  template = null;
}


My problem is, if I change the value in cell 2 of any row, template.getDataProperty("value",row,i) ALWAYS gives me the value of cell 2.
I've checked all variables, they do have the correct value ...
Sorry if the answer is stupid, but I'm new to JS and ActiveWidgets grid :)
Aurélien
July 27,

This topic is archived.

See also:


Back to support forum