PDA

View Full Version : [CLOSED] RAZOR javascript / gridpanel issue getActiveRecord.set



OriCoder
Apr 21, 2013, 11:04 PM
Hi Guys

Trying to set and value on an other column after changing a drop and with blur, of the back of a combobox, edit in a gridpanel

This Works


l.Blur.Handler = "App." + "GridPanel_" + TempData["tabNumber"] + ".editingPlugin.getActiveRecord().set('AccountId',' 64');";

..... Gives me back the value and my renderer displays what I expect

This does not


l.Blur.Handler = "App." + "GridPanel_" + TempData["tabNumber"] + ".editingPlugin.getActiveRecord().set('AccountId',g etDefaultAccount(App." + "GridPanel_" + TempData["tabNumber"] + ".editingPlugin.getActiveRecord().get('partyId')));";

Trying to do it dynamically

Javascript function run and gives back the expected value


var getDefaultAccount = function (counterpartyId) {

Ext.net.DirectMethod.request({
url: 'ExtNet/getDefaultAccount?partyId=' + partyId,
success: function (result) {
var str = '' + result.data;
return str;
}
});
}



.... Stuck

Daniil
Apr 22, 2013, 6:46 AM
Hi @OriCoder,

A DirectMethod call is asynchronous. It means that the getDefaultAccount function executes before a DirectMethod call gets a response.

You should update a record within the DirectMethod's success handler.

OriCoder
Apr 23, 2013, 10:29 PM
Hi @OriCoder,

A DirectMethod call is asynchronous. It means that the getDefaultAccount function executes before a DirectMethod call gets a response.

You should update a record within the DirectMethod's success handler.

Yeh I know I can do that but the bit I always get stuck on in my head, how do tell which row and tab I am on ....

With...


l.Blur.Handler = "App." + "GridPanel_" + TempData["tabNumber"] + ".editingPlugin.getActiveRecord().set('SettlementAc countId',getDefaultAccount(App." + "GridPanel_" + TempData["tabNumber"] + ".editingPlugin.getActiveRecord().get('Counterparty Id')));";

I can reference the things correctly but in the response from the direct method this won't work.



App.GridPanel_ ( ?? gridId ?? ).editingPlugin.getActiveRecord().set('SettlementA ccountId',result.data);


not getting how best to do it.

Daniil
Apr 24, 2013, 9:25 AM
Within a DirectMethod's success handler you can access variables of the outer scope.

Example

var getDefaultAccount = function () {
var record = getRecord();

Ext.net.DirectMethod.request({
url: "someUrl",
success: function (result) {
alert(record);
}
});
};

OriCoder
Apr 24, 2013, 9:43 AM
Within a DirectMethod's success handler you can access variables of the outer scope.

Example

var getDefaultAccount = function () {
var record = getRecord();

Ext.net.DirectMethod.request({
url: "someUrl",
success: function (result) {
alert(record);
}
});
};

i'll have a look but I'm sure I tried that abd was getting record undefined. But that might have been when I was trying to pass record from the ext code in the view not the javascript

Daniil
Apr 24, 2013, 10:28 AM
If the issue persists, please provide a test case to reproduce.

OriCoder
Apr 24, 2013, 5:58 PM
got it working now, had tried that before but keep crashing the browser, but passing the row with



l.Blur.Handler = "getDefaultAccount(App." + "GridPanel_" + TempData["tabNumber"] + ".editingPlugin.getActiveRecord());";


Then using



var getDefaultAccount = function (record) {

//var record = getRecord();

Ext.net.DirectMethod.request({
url: 'ExtNet/getDefaultAccount?partyId=' + record.get('partyId'),
success: function (result) {
record.set('AccountId',result.data);
}
});
}


Done the trick, consider this closed