jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Grid JS error on LoadState › Reply To: Grid JS error on LoadState
hi…
i created function in javascript file,and refernce this file in a view.
i want to return string from function in javacript file and use this in view when converting it to json object
function is:
function configJsonSource(id, async, urlSource, urlAdd, urlUpdate, rowid, rowdata, p1, d1, p2, d2, p3, d3, p4, d4, p5, d5, p6, d6, p7, d7, p8, d8, p9, d9, p10, d10, p11, d11, p12, d12, p13, d13, p14, d14, p15, d15, p16, d16, p16, d16, p17, d17, p18, d18, p19, d19, p20, d20, p21, d21, p22, d22, p23, d23, p24, d24, p25, d25, p26, d26, p27, d27, p28, d28)
{
var source = ‘ { dataType: “json”,dataFields: [‘;
for (i = 7 ; i < arguments.length; i=i+2)
{
if (i ==arguments.length-1)
source = source + ‘{ name: \” + arguments[i] + ‘\’, type: \” + arguments[i + 1] + ‘\’ }’;
else
source = source + ‘{ name: \” + String(arguments[i]) + ‘\’, type: \” + arguments[i + 1] + ‘\’ },’;
}
source = source.slice(0, source.length – 1);
source = source + ‘],id: \” + id + ‘\’,async:’ + async + ‘,url:\” + urlSource + ‘\’},’;
source = source + ‘ addrow: function (rowid, rowdata, position, commit){ $.ajax({url: \” + urlAdd + ‘\’,data:rowdata ,type:”Post”,success: function (data, status, xhr) {$(“#jqxgrid”).jqxGrid(\’updatebounddata\’, \’cells\’);’;
source=source+’},error:function(jqXHR, textStatus, errorThrown) { alert(“error ajax”);alert(JSON.stringify(errorThrown, null, 3)); commit(false);}});’;
//
source = source + ‘},updaterow: function (rowid, rowdata, commit) { $.ajax({ url: \” + urlUpdate + ‘\’, data:rowdata , type:”Post”,’;
source = source + ‘success: function (data, status, xhr) {$(“#jqxgrid”).jqxGrid(\’updatebounddata\’, \’cells\’);},’;
source=source+’ error:function(jqXHR, textStatus, errorThrown) { alert(“update row:”); alert(JSON.stringify(errorThrown, null, 3)); commit(false);}});’;
source = source + ‘}};’;
return source;
}
and in view i used var source = JSON.parse(configJsonSource(id, false, urlSource, urlAdd, urlUpdate, ”, ”, ‘Req_id’, ‘number’, ‘Req_number’, ‘number’, ‘Req_date’, ‘date’, ‘Req_Dep’, ‘number’, ‘DepDesc’, ‘string’, ‘Req_Occasion’, ‘number’, ‘OccDesc’, ‘string’, ‘Req_persons’, ‘number’, ‘Req_Occasion_date’, ‘date’, ‘Req_Items’, ‘string’, ‘Req_price’, ‘double’, ‘Req_Occasion_place’, ‘number’, ‘PlaceDesc’, ‘string’, ‘Req_Evaluation’, ‘string’, ‘EvalDesc’, ‘string’, ‘Req_Note’, ‘string’, ‘flowstatus’, ‘number’, ‘nextflowstep’, ‘number’, ‘nextflowstepDesc’, ‘string’, ‘checkRoleFlowStep’, ‘number’, ‘PreviousFlowstep’, ‘number’, ‘PreviousFlowstepDesc’, ‘string’, ‘CanEdit’, ‘number’, ‘FlowLabel’, ‘string’, ‘cd’, ‘date’, ‘md’, ‘date’, ‘cu’, ‘string’, ‘mu’, ‘string’));
but it does nt work,ant help?