[0.8.2] Error Getting AjaxMethod Value

  1. #1

    [0.8.2] Error Getting AjaxMethod Value

    Hey all,

    I'm using a codebehind process for modifying the dataObject before saving, deleting and inserting.
    For that I pass the record from the ProductsStore to the codebehind as a parameter.

    I'm using also a Function (CheckData) to commit the Data Changes before the event

            var CheckData = function () {
                if (!#{FormPanel1}.getForm().isValid()) {
                    
                    return false;
                }
                #{FormPanel1}.getForm().updateRecord(#{ProductsStore}.getAt(0));
                #{ProductsStore}.commitChanges();
                return true;
            }

    For testing, I'm using MessageBox to show the entity.
        protected void MenuItem7_Click(object sender, AjaxEventArgs e)
        {
            
            Ext.Msg.Alert("AjaxEvent", string.Format("Item - {0}", e.ExtraParams["ProductEntity"])).Show();
        }
    <ext:ToolbarButton ID="BtnSave" runat="server" Icon="Disk" Text="Enregistrer">
        <AjaxEvents>
            <Click OnEvent="MenuItem7_Click" Before="CheckData()">
                <ExtraParams>
                    <ext:Parameter Name="ProductEntity" Value="#{ProductsStore}.getRecordsValues()"
                        Mode="Raw" Encode="true" />
                </ExtraParams>
            </Click>
        </AjaxEvents>
        <ToolTips>
            <ext:ToolTip ID="ToolTip7" runat="server" Html="enregistrement." />
        </ToolTips>
    </ext:ToolbarButton>


    My problem is that I cannot get the updated data in the codebehind directly.
    For example, if I change the ProductName in the formPanel, I cannot get this modified data only if I click another time the saveBtn

    Here you are the scenario :
    1) I change the product name YYYY to XXXX.
    2) I click Save
    3) The product name passed to the codebehind is YYYY
    4) I click save again
    5) The product name passed to the codebehind is now XXXX


    So, what's wrong ?? I checked the ProductsStore.getRecordsValues with FireBug. It return the productName XXX during the first click.



    Thanks again for you help.
  2. #2

    RE: [0.8.2] Error Getting AjaxMethod Value

    Hi,

    Before handler is called after params building. The reasone: to give ability to change params in the Before handler


    Possible solutions:


    1. Add click listener and call 'CheckData' in that listener. It is guarantee that record updating will be performed before AjaxEvent


    or


    2. Get data in the CheckData. Change CheckData signature
    CheckData (el, type, action, extraParams)
    And use the following code inside CheckData
    extraParams.ProductEntity = ProductsStore.getRecordsValues();

    As you can see option 1 requires less coding
  3. #3

    RE: [0.8.2] Error Getting AjaxMethod Value

    It's perfect !! Thank a lot for your help !!

    You can mark it as solved :)


    Best regards.

Similar Threads

  1. Error 404.15 on AjaxMethod.Request with JSon
    By Spootnick in forum 1.x Help
    Replies: 1
    Last Post: Jun 16, 2011, 4:31 PM
  2. [CLOSED] [0.8] MVC 2 and AjaxMethod Error
    By fondant in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 02, 2010, 8:24 AM
  3. TabPanel ActiveTab.ID error in AjaxMethod
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 08, 2008, 6:57 AM
  4. [CLOSED] AjaxMethod Error = BADRESPONSE: Syntax error
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 05, 2008, 6:37 PM
  5. [CLOSED] AjaxMethod error
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Nov 06, 2008, 8:52 AM

Posting Permissions