tabalinas/jsgrid

Select Field : is it possible to reload via ajax on editTemplate?

Open

#842 建立於 2017年7月14日

在 GitHub 查看
 (11 留言) (0 反應) (0 負責人)JavaScript (356 fork)batch import
help wanted

倉庫指標

Star
 (1,520 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Is it possible to reload select field items on it field self when editTemplate is called? I try to do like this but not running sorry my English is not good

 {title:"Category",type:"select", name:"prodCatId", items:dataCategory,valueField:"prodCatId",textField:"prodCatDesc",
  editTemplate : function(){
   var sbuField = this._grid.fields[0];
   var $editControl = jsGrid.fields.select.prototype.editTemplate.call(this,arguments);
    
    $editControl.on("change", function(){
     var selectedSbuId = sbuField.editControl[0].value;
     var selectedprodCatId = $(this).val();
     $.ajax({
      type: "POST",
       url: "./getDataCategoryList",
       data:{"sbuId":selectedSbuId,"prodCatId":selectedprodCatId},
       success: function(data){
        dataCategory =  data
       },
       error : function(error){alert('error')}
      }); 
    });
    return $editControl;
 },
}

貢獻者指南