[CLOSED] RAZOR javascript / gridpanel issue getActiveRecord.set

  1. #1

    [CLOSED] RAZOR javascript / gridpanel issue getActiveRecord.set

    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',getDefaultAccount(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
    Last edited by Daniil; Apr 24, 2013 at 5:17 PM. Reason: [CLOSED]
  2. #2
    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.
  3. #3
    Quote Originally Posted by Daniil View Post
    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('SettlementAccountId',getDefaultAccount(App." + "GridPanel_" + TempData["tabNumber"] + ".editingPlugin.getActiveRecord().get('CounterpartyId')));";
    I can reference the things correctly but in the response from the direct method this won't work.

    App.GridPanel_ ( ?? gridId ?? ).editingPlugin.getActiveRecord().set('SettlementAccountId',result.data);
    not getting how best to do it.
  4. #4
    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);
            }
        });
    };
  5. #5
    Quote Originally Posted by Daniil View Post
    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
  6. #6
    If the issue persists, please provide a test case to reproduce.
  7. #7
    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

Similar Threads

  1. [CLOSED] Razor GridPanel - Strange issue
    By OriCoder in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 18, 2013, 9:28 PM
  2. Replies: 0
    Last Post: Oct 22, 2012, 8:36 AM
  3. Replies: 2
    Last Post: Jul 10, 2012, 1:23 PM
  4. Replies: 1
    Last Post: May 11, 2012, 12:57 PM
  5. [CLOSED] [Razor] Add GridView to GridPanel in razor
    By boris in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 09, 2012, 4:23 PM

Tags for this Thread

Posting Permissions