Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3740

Custom Field being not accessed

$
0
0

Hi,
I have a custom field named RO_Category with three number of buttons just alike todo list where only one button can be enabled at a time. Based upon the selection of these buttons, I want to have updated another field(not custom one) with select type.
Here is how I defined the custom field **RO_Category **

_fieldTypes.RO_Category = {
create: function ( conf ) {
  var that = this;

  conf._enabled = true;

  // Create the elements to use for the input
  conf._input = $(
      '<div id="'+Editor.safeId( conf.id )+'">'+
          '<button type="button" style="margin-right:2px;" id="btn1" class="inputButton" value="TPDS" data-toggle="tooltip"  data-placement="top" title="Targetted Public Distribution System">TPDS</button>'+
          '<button type="button" class="inputButton" id="btn2" value="OWS"  data-toggle="tooltip"   data-placement="top" title="Other Welfare Schemes">OWS</button>'+
           '<button type="button" class="inputButton" id="btn3" value="OMSS" data-toggle="tooltip"  data-placement="top" title="Open Market Sale Scheme">OMSS</button>'+
          
      '</div>');

  
  $('button.inputButton', conf._input).click( function () {
      if ( conf._enabled ) {
          that.set( conf.name, $(this).attr('value') );
          }

      return false;
  } );

  return conf._input;
},

get: function ( conf ) {
  return $('button.selected', conf._input).attr('value');
},

set: function ( conf, val ) {
  $('button.selected', conf._input).removeClass( 'selected' );
  $('button.inputButton[value='+val+']', conf._input).addClass('selected');
},

enable: function ( conf ) {
  conf._enabled = true;
  $(conf._input).removeClass( 'disabled' );
},

disable: function ( conf ) {
  conf._enabled = false;
  $(conf._input).addClass( 'disabled' );
}
};

In my index file, I have included these fields as below

{
          label: "RO_Category:",
          name: "RO_Category",
           type: "RO_Category",
          options: [ "TPDS", "OWS","OMSS" ],
          def : "TPDS",
        },
        {
          label: "RO_Sub_Category:",
          name: "RO_Sub_Category",
          type: "select",
        },

In order to have changed the select options of 2nd field based on selection of my custom field, i used following code

editor.field( 'RO_Category' ).input().on( 'change', function ()
                {
                  var scheme=editor.field( 'RO_Category' ).get();
                  if(scheme=='OWS')
                  {
                    editor.field('RO_Sub_Category').update(["MDM-Primary", "MDM-Upper Primary", "SAG","Defence","WIS"]);   
                  }
                  
                });

But, clicking on my custom buttons do nothing.
Please help me resolve this issue.

Regards
Shatrughan Sangwan


Viewing all articles
Browse latest Browse all 3740