Sigma Php Ajax framework, Ajax Components, GUI Builder
May 21, 2012, 08:34:23 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: Problem with checkbox  (Read 1254 times)
cbd
Full Member
***
Posts: 30


View Profile
« on: January 04, 2009, 07:31:15 PM »

I have a checkbox in a cell to mark a state Yes or Not. I have the following code in column options.

var colsOption = [
   {id: 'fondo_reserva' , header: "Fondo Reserva" , width :120, renderer : function(value, record, columnObj, grid, colNo, rowNo) {
   var no= grid.getColumnValue('fondo_reserva', rowNo);
   return "<input type=\"checkbox\" value=\"" + no + "\"" + (valor == "Si" ? " checked" : "") + " onclick=\"fondo_check(this)\" />";
    }},
    ......
    ......
];

The function fondo_check became as follow:

function fondo_check(objeto) {
   if( objeto.value == 'No' || objeto.value == 'null' ) {
      objeto.value = "Si";
   }
   else {
      objeto.value = "No";
   }
};

The question is how can I update the field value? so when I save the data the value of the field it's updated.

Thanks
Logged
cbd
Full Member
***
Posts: 30


View Profile
« Reply #1 on: January 05, 2009, 12:54:39 PM »

I have a checkbox in a cell to mark a state Yes or Not. I have the following code in column options.

var colsOption = [
   {id: 'fondo_reserva' , header: "Fondo Reserva" , width :120, renderer : function(value, record, columnObj, grid, colNo, rowNo) {
   var no= grid.getColumnValue('fondo_reserva', rowNo);
   return "<input type=\"checkbox\" value=\"" + no + "\"" + (valor == "Si" ? " checked" : "") + " onclick=\"fondo_check(this)\" />";
    }},
    ......
    ......
];

The function fondo_check became as follow:

function fondo_check(objeto) {
   if( objeto.value == 'No' || objeto.value == 'null' ) {
      objeto.value = "Si";
   }
   else {
      objeto.value = "No";
   }
};

The question is how can I update the field value? so when I save the data the value of the field it's updated.

Thanks


Continuing with the topic, I did a few modifications in the code such as:
In the function renderer the line of return now say
return "<input type=\"checkbox\" name=\"checkcajaFR_" + rowNo + "\" value=\"" + no + "\" " + (valor == "Si" ? " checked" : "") + " onclick=\"fondo_check(this)\" />";

I added name attribute where checkcajaFR_1 contains the line number of the record (number 1) and function fondo_check stayed as:

fondo_check(objeto) {
   // Here extracting the row number
        var rowNO = parseInt(objeto.name.substring(objeto.name.search(/_/) + 1, objeto.name.length));
   if( objeto.checked ) {
      objeto.value = "Si";
      mycuentasgrid.setColumnValue("fondo_reserva", rowNO, "Si");
   }
   else {
      objeto.value = "No";
      mycuentasgrid.setColumnValue("fondo_reserva", rowNO, "No");
   }
};

This work fine only with existing records (I mean records loaded from backend database) but not on inserted records.
When I add a new record to grid,  I click on the checkbox, I fill my others fields and I click on save icon, the data is saved in backend DB but field corresponding to checkbox is not updated staying with default value "No".
   
Somebody can tell me why this happens ?

Thanks in advance
« Last Edit: January 05, 2009, 12:56:13 PM by cbd » Logged
humi
Hero Member
*****
Posts: 284


View Profile
« Reply #2 on: January 05, 2009, 01:14:24 PM »

About your problem:

It isn't your code. It is a limitation that SigmaGrid has (i believe)

I also ran into this problem when i wanted one custom editor's results dynamic to the result of another. ie.


With the structure above, a job for "Client 1" will receive a different rate than a job for "Client 2". For me to know what dropdown list to generate, i need to know what the newly entered data is for the field of Client.

This doesn't help, but shows another practical example of the problem.
I'm also looking for a solution.

Maybe a staff member can let us know if there is a solution to this.
Logged
stani
Jr. Member
**
Posts: 14


View Profile
« Reply #3 on: January 30, 2009, 04:09:39 AM »

Hi,

This is a common problem faced by many developers. Can a staff of SigmaGrid kindly reply to this post. It will be highly appreciated!!

Thanks.
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!