3.2.0

set cell selection color

I have read through the forum posts and have been unable to find an answer to a problem I am having.

After selecting a cell, I am having trouble setting the background and foreground colors for that particular cell.

Is there an example out there that illustrates how to do this?

Thanks,
Glenn
Glenn Leidy
August 9,
I would also like to format the selected cell. Is there a way to do this through javascript?
August 19,
Anyone have a solution for this yet?
August 24,
this should work - but not working :-( perhaps I'm missing something small.

obj.cellClicked = function(src){
    //alert('row,col=' + src.getRowProperty("index") + ',' + src.getColumnProperty("index"));
    var divStyleId = "div#" + this.getId() + ".data.item:" + src.getRowProperty("index") + ".item:" + src.getColumnProperty("index");
    alert(src + "\n\n" + divStyleId);
    this.styleSheet.addRule(divStyleId, "color: red!important"); 
  };
  //  set click action handler
  obj.setAction("click", obj.cellClicked);
Sudhaker Raj
August 24,
It appears the individual cells do not have an ID... that is why it is not working.
August 24,
They do have... here is dump for a generated row :-(

<div id="grid1.data.item:1" class="active-templates-row active-grid-row active-list-item " style="background:#fff;" onclick="dispatch(event,this)" onmouseover="mouseover(this, 'active-row-highlight')" onmouseout="mouseout(this, 'active-row-highlight')">
  <div id="grid1.data.item:1.item:0" class="active-templates-text active-row-cell active-grid-column active-list-item active-column-0 " onclick="dispatch(event,this)">
    ORCL</div>
  <div id="grid1.data.item:1.item:1" class="active-templates-text active-row-cell active-grid-column active-column-1 " onclick="dispatch(event,this)" onfocus="dispatch(event,this)">
    Oracle Corporation</div>
  <div id="grid1.data.item:1.item:2" class="active-templates-text active-row-cell active-grid-column active-column-2 " style="color:transparent;" onclick="dispatch(event,this)" onfocus="dispatch(event,this)">
    62,615.26</div>
  <div id="grid1.data.item:1.item:3" class="active-templates-text active-row-cell active-grid-column active-column-3 " onclick="dispatch(event,this)" onfocus="dispatch(event,this)">
    06/02/2004</div>
  <div id="grid1.data.item:1.item:4" class="active-templates-text active-row-cell active-grid-column active-list-item active-column-4 " onclick="dispatch(event,this)">
    40650</div>
</div>
[code]

I tried something like this also (with no luck) 

[code]
/* third column of selected row(s) */
#grid1 active-selection-true active-column-2 {color: red!important;}


Sudhaker Raj
August 24,
I wonder how to generate a dump of the in memory generated code; can you shortly explain how to get such a dump?
Andreas
March 24,
I think this will dump that code:

image.setAction("click", function(src){
alert (src);
}
jeremy
April 23,
Here is the code I use to set color of cell clicked


//initially set rowNo to -1 to indicate no click has happened
<input type="hidden" ID="RowNo" NAME="RowNo" value="-1">
<input type="hidden" ID="ColumnNo" NAME="ColumnNo">

//set cell selection to null because we are selecting a particular cell
obj.setAction("selectRow", null);

obj.cellClicked = function(src){
//change the selected cell color
//first need to reset the color of previously clicked cell
row=src.getRowProperty("index");col=src.getColumnProperty("index");
//id of current cell click
var divID=this.getId()+".data.item:"+row+".item:"+col;
//row and column of last clicked cell
var prevRow=document.getElementById('RowNo').value;
var prevCol=document.getElementById('ColumnNo').value;
//if row is not -1 :- reset the previous cell click color
if(prevRow != -1){
var divIDprevCell=this.getId()+".data.item:"+prevRow+".item:"+prevCol;
document.getElementById(divIDprevCell).style.background = "white";
}
//change current cell color to yellow
document.getElementById(divID).style.background = "yellow";

//Get the value of build
var BuildValue=myData[col][row];

document.getElementById('Build').value=BuildValue;
if(row==0 || BuildValue=='&nbsp;'){
document.getElementById('Build').value="";
}
//store value of current cell clicked -it will be used in next click
document.getElementById('RowNo').value=row;
document.getElementById('ColumnNo').value=col;


};
// set click action handler
obj.setAction("click", obj.cellClicked);



Sonika
February 3,
PLease ignore the following lines of code from my previous reply. I just copied from my source file as it is

//Get the value of build
var BuildValue=myData[col][row];

document.getElementById('Build').value=BuildValue;
if(row==0 || BuildValue=='&nbsp;'){
document.getElementById('Build').value="";
}
Sonika
February 3,
How would one do this on double click?
Neil Craig
March 29,

This topic is archived.

See also:


Back to support forum