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

conditionally disable radio button in datatable

Expand Messages
  • mary_09876
    I have a yui datatable where the first column holds a set of radio buttons -- just radio buttons, not inline radio editors. How do I go about conditionally
    Message 1 of 2 , Jun 30, 2009
    • 0 Attachment
      I have a yui datatable where the first column holds a set of radio buttons -- just radio buttons, not inline radio editors. How do I go about conditionally disabling some of the radio buttons? I've distilled the relevant code snippet below.

      Thanks ahead,
      -Mary





      var columnDefs = [
      {key:"selectRadio", label:"", formatter:"radio"},
      {key:"name", label:"Name"},
      {key:"type", hidden:true}
      ];

      var dataSource = new YAHOO.util.DataSource(someDatasource);
      dataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
      dataSource.responseSchema = {
      resultsList: "records",
      fields: ["name", "type"]
      };

      var configs = {
      dynamicData: true,
      formatRow: rowFormatter
      };

      var dataTable = new YAHOO.widget.DataTable("container", columnDefs, dataSource, configs);


      var rowFormatter = function(elTr, oRecord) {
      if(oRecord.getData('type') == "inactive") {
      var radioTdEl = this.getFirstTdEl(elTr);
      // TODO: disable the radio button in this cell
      }
      return true;
      };
    • Satyam
      Drop the selectRadio column and show the type column instead with your own formatter that will show an enabled or disabled radio button. Forget about the row
      Message 2 of 2 , Jun 30, 2009
      • 0 Attachment
        Drop the selectRadio column and show the type column instead with your
        own formatter that will show an enabled or disabled radio button.
        Forget about the row formatter, the row formatter is called before the
        individual cell formatters so you won't find the radio button at that time.

        Satyam


        mary_09876 escribió:
        > I have a yui datatable where the first column holds a set of radio buttons -- just radio buttons, not inline radio editors. How do I go about conditionally disabling some of the radio buttons? I've distilled the relevant code snippet below.
        >
        > Thanks ahead,
        > -Mary
        >
        >
        >
        >
        >
        > var columnDefs = [
        > {key:"selectRadio", label:"", formatter:"radio"},
        > {key:"name", label:"Name"},
        > {key:"type", hidden:true}
        > ];
        >
        > var dataSource = new YAHOO.util.DataSource(someDatasource);
        > dataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
        > dataSource.responseSchema = {
        > resultsList: "records",
        > fields: ["name", "type"]
        > };
        >
        > var configs = {
        > dynamicData: true,
        > formatRow: rowFormatter
        > };
        >
        > var dataTable = new YAHOO.widget.DataTable("container", columnDefs, dataSource, configs);
        >
        >
        > var rowFormatter = function(elTr, oRecord) {
        > if(oRecord.getData('type') == "inactive") {
        > var radioTdEl = this.getFirstTdEl(elTr);
        > // TODO: disable the radio button in this cell
        > }
        > return true;
        > };
        >
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        > ------------------------------------------------------------------------
        >
        >
        > No virus found in this incoming message.
        > Checked by AVG - www.avg.com
        > Version: 8.5.375 / Virus Database: 270.13.1/2211 - Release Date: 06/30/09 11:37:00
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.