-
23 Jul 2009 7:14 AM #1
if = missing : after property id
if = missing : after property id
Hello, i understand this measage, but how i can make a IF in the params: property?
i get alwas a erro like this:Code:function saveRecord(oGrid_event){ Ext.Ajax.request({ waitMsg: 'Please wait...', url: 'database.asp', params: { if (oGrid_event.record.data.task == "create") {task: 'create';}, else {task: 'update';}, ObjectOrder: oGrid_event.record.data.ObjectOrder, ObjectTypeID: oGrid_event.record.data.ObjectTypeID, Name: oGrid_event.record.data.Name }, success: function(response){ var result=eval(response.responseText); switch(result){ case 1: store.commitChanges(); store.reload(); break; default: Ext.MessageBox.alert('Uh uh...','We couldn\'t save him...'); break;} }, failure: function(response){ var result=response.responseText; Ext.MessageBox.alert('error','could not connect to the database. retry later');} }); };
missing : after property id
function(){\n
Many thanks for all help!
best regards
Jaroslaw
-
23 Jul 2009 7:53 AM #2
try this:if (oGrid_event.record.data.task == "create")
{task: 'create';},
else
{task: 'update';},
You can not add if ... else ... as the params' property!task: oGrid_event.record.data.task == "create"?"create":"update",
....
-
23 Jul 2009 7:55 AM #3
This is not an Ext issue - it's JavaScript. You can't use an if inside an object declaration. You could do
Code:params :{ task: oGrid_event.record.data.task == "create" ? "create" : "update"} }Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
23 Jul 2009 9:15 AM #4
Hello fanzhongkai and tryanDLS,
many thanks for fast reply both. I understand that this is no a ExtJS issue. This help me to use this powerfull and great Extension. I still testing but very impressiv. Many thanks again!
My code now:
brCode:params: { task: oGrid_event.record.data.task == "create" ? "create" : "update", ObjectOrder: oGrid_event.record.data.ObjectOrder, ObjectTypeID: oGrid_event.record.data.ObjectTypeID, Name: oGrid_event.record.data.Name },
Jaroslaw Kucharski


Reply With Quote