Sigma Php Ajax framework, Ajax Components, GUI Builder
February 09, 2012, 10:22:50 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Back color of a row  (Read 4568 times)
jareyesb
Jr. Member
**
Posts: 11


View Profile
« on: January 23, 2009, 06:18:13 PM »

Hi everyone,

I know that this is a question that i made before yesterday but until now i implement the answer that steven gave me, but it doesnt work, i'm pretty sure that i am making a mistake but either i want to show my code.

i want to set the backgroundColor of a row depending of certain value of a cell so i have this (function gridCompleted(grid) is what Steven said):

<script type="text/javascript">
<!--
var grid_demo_id = "";
var dsOption = "";
var colsOption = "";
var gridOption = "";

function asignaVariables() {
   grid_demo_id = "myGrid1" ;
   
   dsOption= {
      fields :[
         {name : 'PMM_DATETIME' ,type:'date'},
         {name : 'RED'  },
         {name : 'BEST'  },
         {name : 'BKP1'  },
         {name : 'BKP2'  },
         {name : 'BKP3'  }
         
      ],
      recordType : 'array'
   }
   
   colsOption = [
       {id: 'PMM_DATETIME' , header: "Fecha" , width :120  },
       {id: 'RED' , header: "Red" , width :110  },
         {id: 'BEST' , header: "Best" , width :160  },
         {id: 'BKP1' , header: "BackUp 1" , width :160},
         {id: 'BKP2' , header: "BackUp 2" , width :160},
         {id: 'BKP3' , header: "BackUp 3" , width :160}
   ];

   gridOption={
      id : grid_demo_id,
      loadURL : 'main-controller.php',
      saveURL : 'main-controller.php',
      parameters : {crouter: document.getElementById("router").value}, //Amsterdam RRC001 New York RRC111
      width: "1000",  //"100%", // 700,
      height: "500",  //"100%", // 330,
      container : 'gridbox',
      replaceContainer : true,
      encoding : 'UTF-8', // Sigma.$encoding(),
      dataset : dsOption ,
      columns : colsOption ,
      pageSize:100,
      toolbarContent : 'nav | pagesize | reload print state',
      skin: 'mac'
   };
}

function consultaDatos() {
   document.getElementById("content").innerHTML = '<div id="gridbox" style="border:0px solid #cccccc;background-color:#f3f3f3;padding:5px;height:500px;width:1000px;" ></div>';
   var mygrid=new Sigma.Grid( gridOption );
   mygrid.render();
   //Sigma.Util.onLoad(function(){mygrid.render()});
}

function gridCompleted(grid){
    var trArray = Sigma.Grid.getAllRows(grid);
    for(var i=0;i<trArray.length;i++){
      data = grid.getRecord(i);
      if(data[4] == " - "){
        trArray.style.backgroundColor = "red";
      }
    }
}

function window_onload() {
   asignaVariables();
   consultaDatos();
   gridCompleted('myGrid1');
}

//-->
</script>
Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #1 on: January 24, 2009, 06:46:05 PM »

If it is not working, what does it do instead?

The function steven posted is different from yours. if you replace this one line, it may work:



also, you may have a conflict with the data[4] variable.

instead, try this:
Logged
jareyesb
Jr. Member
**
Posts: 11


View Profile
« Reply #2 on: January 26, 2009, 10:01:20 AM »

when i call the function gridCompleted(grid) and alert the trArray like this:
    function gridCompleted(grid){
       var trArray = Sigma.Grid.getAllRows(grid);
       alert(trArray);

it's empty, i mean it looks like if the parameter grid of the function, which in my case i think must be the value of the variable grid_demo_id which i defined at the beggining of the script:


Logged
jareyesb
Jr. Member
**
Posts: 11


View Profile
« Reply #3 on: January 26, 2009, 10:05:39 AM »

...sorry, accidentally i post before, the variable grid_demo_id = "myGrid1" is the parameter of the function, but the array produced by the Sigma.Grid.getAllRows is empty, its possible that i'm passing bad the parameter grid in gridCompleted(grid) Huh, Is this parameter the id option in gridOption collection Huh

 gridOption={
      id : grid_demo_id,
      loadURL : 'main-controller.php',
      saveURL : 'main-controller.php',
      parameters :

Thanks for your time, sorry for my english Smiley
Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #4 on: January 26, 2009, 10:24:21 AM »

You should be using the instance. ie:



You should use the functions in the object ie: mygridinstance1.getAllRows()
- not through the SigmaGrid script ie: Sigma.Grid.getAllRows()

I'm not sure why this is. But it has been working for me. I run in to problems using the Sigma.Grid.function inside the grid object.

Try to alert(trArray) with the code above.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!