Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Custom editing in datatable....

Expand Messages
  • Satyam
    If you search in datatable-beta.js for: YAHOO.widget.DataTable.editRadio You ll see a line tha reads: var radioOptions = oColumn.editorOptions.radioOptions;
    Message 1 of 2 , Oct 3, 2007
    • 0 Attachment
      If you search in datatable-beta.js for:
       
      YAHOO.widget.DataTable.editRadio
       
      You'll see a line tha reads:
       
       var radioOptions = oColumn.editorOptions.radioOptions;
       
      That loads the options from the column definitions.  You would want to change this line to read those options from elsewhere.
       
      So, copy that method to your own script file, rename it and change the way it reads the radioOptions.  Then, in the column definition, instead of saying
       
      editor:'radio'
       
      you asign it a reference to your own function
       
       
      ----- Original Message -----
      Sent: Wednesday, October 03, 2007 1:46 PM
      Subject: [ydn-javascript] Custom editing in datatable....

      Hi

       

      I have the following requirement.

       

      Based on the type of the editor that is passed as an element in the record,

      I need to display the editor with the possible_values field in the record.

       

      Eg: Sample record will be as follows

       

      {Name:”Some Name1”, value:”false”, editbox:”radio”,possible_values:”true,false,somethingelse”}

      {Name:”Some Name2”, value:”op1”, editbox:”checkbox”,possible_values:”op1,op2,op3”}

       

       

       

      I have seen the datatable editing sample which does this, but the possible values in the editor are static.

       

      I,e

       

                  {key:"active", editor:"radio", editorOptions:{radioOptions:["yes","no","maybe"],disableBtns:true}},

                  {key:"colors", editor:"checkbox", editorOptions:{checkboxOptions:["red","yellow","blue"]}},

       

      As you can see yes, no, maybe, red, blue, green are the values that are used at the creation time.

       

      But I want to do this at runtime, I’e based on the field in the record.

       

       

      So I have written the following code

       

      for(i=1 to n)

      {

      Row = {Name:arr[name] value:arr[value], editbox:arry[type],possible_values:arr[possible_values]}

      Datatable.add(row).

       

      }

       

       

      I have the following function which is pointer by the editor parameter of the data table .

       

       

       

      datatable.customformating = function(oEditor, oSelf)

      var elCell = oEditor.cell;

                  var oRecord = oEditor.record;

                  var oColumn = oEditor.column;

                  var elContainer = oEditor.container;

                  var value = oRecord.getData(oColumn.key);

                 

                    var type=oRecord.getData("editbox");

                    if(type=="radio")

                    {

                             var tmpArr = oRecord.getData("possible_values").split(",");

                              for(var i=0; i< tmpArr.length; i++)

                              {

                                  //alert(tmpArr[i]);

                                  //var elCheckbox = elContainer.appendChild(document.createElement("input"));

                                  var textNode = document.createTextNode(tmpArr[i]);

                                  var elCheckbox = document.createElement("input");

                                  elCheckbox.type = "radio";

                                  elCheckbox.name = elCell.id+”_r”;

                                  //elCheckbox.value = tmpArr[i];

                                  elContainer.appendChild(textNode);

                                  elContainer.appendChild(elCheckbox);

                              }

                  }

       

       

       

               I get the dynamic radio buttons during edit, but the radio buttons are not getting selected neither the values are getting reflected when I press OK.

       

               Can you please let me know if Im missing something ?

       

               Or is there a better way of doing it ?

       

       

      Thanks

      Prasanna


      No virus found in this incoming message.
      Checked by AVG Free Edition.
      Version: 7.5.488 / Virus Database: 269.13.39/1045 - Release Date: 02/10/2007 18:43
    Your message has been successfully submitted and would be delivered to recipients shortly.