EasyUI Forum

General Category => General Discussion => Topic started by: karogel on November 02, 2016, 01:15:03 AM



Title: How to handle onLoadSuccess if form load was used twice
Post by: karogel on November 02, 2016, 01:15:03 AM
I have this code:
var flag;
function loanproposalshow(){
   var row = $('#dg_application_ci').datagrid('getSelected');
   if (row){
      // open dialog
      $('#dlg_application_proposal').dialog('open').dialog('setTitle','Loan Proposal');

      $('#fm_application_proposal').form('clear');
            
      var url_recom    = 'modules/data/get_loanrecom.php?id='+row.maker_id+'&loanappid='+row.app_loanappid;
      $('#fm_application_proposal').form('load',url_recom);

      $('#fm_application_proposal').form('load',row);
            
      $(function(){
         $('#fm_application_proposal').form({
            onLoadSuccess:function(){
               flag = true;
               calc_recom_apa();
            }
         });
      });
      url = 'modules/application/update_application.php?loanappid='+row.app_loanappid;
   }
}

I am having a problem in calling calc_recom_apa function. It should initiate after the 2 form load and not from the first "form('load',url_recom)"


Title: Re: How to handle onLoadSuccess if form load was used twice
Post by: battlezad on November 02, 2016, 05:43:16 AM
var flag = false;

...

onLoadSuccess:function()
{
               if(flag) calc_recom_apa();
               flag = true;
}


Title: Re: How to handle onLoadSuccess if form load was used twice
Post by: karogel on November 03, 2016, 07:39:10 PM

var url_recom    = 'modules/data/get_loanrecom.php?id='+row.maker_id+'&loanappid='+row.app_loanappid;
$('#fm_application_proposal').form('load',url_recom);

$('#fm_application_proposal').form('load',row);

is the above code OK? i am trying to load the data from "url_recom" and "row" data (from datagrid).

if i will use onLoadSuccess, will it fire after the first form(load ? or after the last form(load or is therea way to comine the 2 data source into single form(load


Title: Re: How to handle onLoadSuccess if form load was used twice
Post by: andyj on November 07, 2016, 03:01:25 AM
If you are trying to combine data from two datasources into one datagrid or into one form, why don't you assemble your data using sql from your multiple datasources and combine it into a single json file?
Then load the data into your datagrid/form with distinct fields (some relating to datasource 1, some relating to datasource 2).
THen when you update/insert/delete, post the form variables to your controller, parse out the respective field values and do your CRUD operations to the 2 different tables/databases in your (Php) controller using the respective field values.

Does that make sense?