Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Pravu Mishra on Jul 21, 2009 05:48
open dhtmlx forum
How to use dataprocesser for saving hidden value of combo.

Hi Alex,

I am using dataprocesser for storing grid values into the database. My grid has two combos and along with other values of grid, I need to pass the value(which is hidden) of combo through the dataprocesser for saving.

 Following code I am using for saving grid data.

function save(){
    var valid = true;
    for (var i=0; i<myDataProcessor.updatedRows.length; i++)
     valid&=myDataProcessor.checkBeforeUpdate(myDataProcessor.updatedRows[i]);
    //if(valid)
    myDataProcessor.sendData();
   }

Could you please let me know how to do this.

Thanks and Regards,

Pravu Mishra.

Answer posted by Alex (support) on Jul 21, 2009 06:39

Hello Pravu,

how do you implement these two combos ?

If you use "combo" excell, the values are passed to server correctly as well as other values of changed rows.

 If you initialize combos in some containers that are placed inside grid cells, you should use onChange event of the combo. You can set userdata or the row with combo with the selected value:

combo.attachEvent("onChange",function(){

grid.setUserData(id,"combo_value",combo.getActualValue())

dp.setUpdated(id.true) /*marks row as updated*/

})

Answer posted by Pravu Mishra on Jul 22, 2009 06:33

 

Hi Alex,

Following is part of my code.

Header

  StringBuffer out= new StringBuffer("");
  out.append("<head>");
  out.append("<column width=\"100\" type=\"ed\" align=\"left\" filter=\"true\" sort=\"str\" >coursesk");
  out.append("</column>");
  out.append("<column width=\"100\" type=\"ed\" align=\"left\" filter=\"true\" sort=\"str\" >Code");
  out.append("</column>");
  out.append("<column width=\"100\" type=\"ed\" align=\"left\" filter=\"true\" sort=\"str\" >Course");
  out.append("</column>");
  out.append("<column width=\"100\" type=\"combo\" align=\"left\" filter=\"true\" sort=\"str\" xmlcontent=\"1\">Faculty");
  out.append(fetchCategoryCombo());
  out.append("</column>");

 

 public String fetchCategoryCombo()throws ClassNotFoundException, SQLException{
  ResultSet rs;
  StringBuffer out= new StringBuffer("");
  startConnect();
  String sql = "select category_sk, category_id from acd_category";
  rs = stmt.executeQuery(sql);

  while (rs.next()){
   out.append("<option value=\"" + rs.getString("category_sk") + "\">" + rs.getString("category_id") +"</option>");
  }
  closeConnect();
  return out.toString();
 }

data part of xml rows for combo

   if(rs.getString("category_desc") != null)
    out.append("<cell>"+convertEscapes(rs.getString("category_desc"))+"</cell>");
   else
    out.append("<cell>"+""+"</cell>");

For this code the combo works. But the problem now is hidden value does not get passed if there is no click happened on the combo. If you click on the combo and select any value then the hidden value gets passed.

Could you please assist and provide your suggestion.

thanks and regards,

pravu Mishra.

Answer posted by Alex (support) on Jul 22, 2009 07:15

Hello, 

the Data Processor only sends data for changed rows. When you open editor and select new option, the grid value is changhed and data is sent to the server. 

In order to send to the server the data from a certain row (chnaged or nor) you can use setUpdated method:

dp.setUpdated(rowId,true);

dp.sendData();