EasyUI Forum
September 15, 2025, 07:54:12 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How can I send selected row data as param to validator function?  (Read 8022 times)
chiefer
Newbie
*
Posts: 10


View Profile Email
« on: July 09, 2014, 08:27:51 PM »

I  create a editable datagrid. When I add or edit a new zone, I need validate the zone code, How can I send selected row data as param to validator function?


<script type="text/javascript">
  $('#tt').edatagrid({
    url: '<?php echo FILENAME_SHIPPING_FEE_TEMPLATE; ?>.php?action=zone_list&shipping_id=<?php echo $shipping_id;?>',
    saveUrl: '<?php echo FILENAME_SHIPPING_FEE_TEMPLATE; ?>.php?action=save_zone&shipping_id=<?php echo $shipping_id;?>',
    updateUrl: '<?php echo FILENAME_SHIPPING_FEE_TEMPLATE; ?>.php?action=update_zone&shipping_id=<?php echo $shipping_id;?>',
    destroyUrl: '<?php echo FILENAME_SHIPPING_FEE_TEMPLATE; ?>.php?action=delete_zone&shipping_id=<?php echo $shipping_id;?>'
  });

$.extend($.fn.validatebox.defaults.rules, {

  check_zone_code: {
    validator: function(value, param){
     $.ajax({
       type: 'POST',
      async: false,
      url:  'shipping_fee_template.php?action=check_zone_code&shipping_id=<?php echo $shipping_id;?>',
      data: {'zone_code':value},
      success: function(result){
        alert(result);
      }
     })
    },
    message: 'The shipping zone already exists.'
  }

});


</script>

<table id="tt" style="height:auto;" title="<?php echo $shipping_info->fields['shipping_name'] . ' ' . TEXT_ZONE_LIST; ?>" url="<?php echo FILENAME_SHIPPING_FEE_TEMPLATE; ?>.php?action=zone_list&id=<?php echo $shipping_id; ?>" toolbar="#zone_toolbar" iconCls="icon-save" rownumbers="true" pagination="true">
<thead data-options="frozen:true">
  <tr>
    <th field="action_button" width="60" rowspan="2">Status</th>
    <th field="id" width="40" rowspan="2">zID</th>
   <th field="shipping_id" width="40" rowspan="2">sID</th>
    <th field="zone_name" width="120" rowspan="2" editor="text"><?php echo TEXT_ZONE_NAME; ?></th>
   <th field="zone_code" width="120" rowspan="2" editor="{type:'validatebox',options:{validType:'check_zone_code'}}"><?php echo TEXT_ZONE_CODE; ?></th>
  </tr>
</thead>
</table>
« Last Edit: July 09, 2014, 08:33:54 PM by chiefer » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 09, 2014, 11:05:01 PM »

Please use the 'onEdit' event to create your validation type, you will be able to get the current editing row data.
Code:
$('#tt').edatagrid({
onEdit:function(index,row){
var ed = $(this).edatagrid('getEditor',{index:index,field:'zone_code'});
$(ed.target).validatebox({
validType:...
})
}
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!