It's seem just can handle there are 6 parameters in Toolchain.Instance.AddFunction, how about I need to pass more parameters?
Because there are complex with my validation, I need to connect to database to get data for some checking, so in my case, I will pass a string field and concate multiple parameters as below in client-side:
var param = par1 + '|' + par2 + '|' + .... + par8
and I use ajax call to pass to backend, then will split these parameters in backend function, I find that just can work find on client-side validation, but not in backend , when the form submit, the backend validation will be failed, because it will not pass these concate parameters at this time.
public static bool CheckDuplicateOrderDate(string parameters)
{
var param = parameters.Split('|');
var order_no = param[0];
var scb_code = param[1];
var item_code = param[2];
var order_cat = param[3];
var order_start_date = param[4];
var order_end_date = param[5];
var campaign_code = param[6];
var source_code = param[7];
//to do other logic....
}
in javascript:
ea.addMethod('CheckDuplicateOrderDate', function (scb_code) {
var form = $(this.__meta__.form);
var order_no = form.find('#order_no').val();
var item_code = form.find('#item_code').val();
var order_cat = form.find('#order_cat').val();
var order_start_date = form.find('#order_start_date').val();
var order_end_date = form.find('#order_end_date').val() ;
var campaign_code = form.find('#campaign_code').val();
var source_code = form.find('#source_code').val();
var parameters = order_no + '|' + scb_code + '|' + item_code + '|' +
order_cat + '|' + order_start_date + '|' + order_end_date + '|' + campaign_code + '|' + source_code
//use ajax to pass to backend
var jqXHR = $.ajax({
url: '/Orders/CheckDuplicateOrderDate',
type: 'POST',
async: false, //disable async for handle the return value
data: {parameters :parameters }
});
return jqXHR.responseJSON;
}
It's seem just can handle there are 6 parameters in
Toolchain.Instance.AddFunction
, how about I need to pass more parameters?Because there are complex with my validation, I need to connect to database to get data for some checking, so in my case, I will pass a string field and concate multiple parameters as below in client-side:
var param = par1 + '|' + par2 + '|' + .... + par8
and I use ajax call to pass to backend, then will split these parameters in backend function, I find that just can work find on client-side validation, but not in backend , when the form submit, the backend validation will be failed, because it will not pass these concate parameters at this time.
below is my register code:
backend function:
in javascript:
in controller
I know this is not a good solution, do you have any ideas?
Thanks!