[CLOSED] Update v2.0 combobox with AjaxResult

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Update v2.0 combobox with AjaxResult

    Hi, We migrated to v2.0 and we have a problem with populate combobox using AjaxProxy.

    Before code:


    <ext:ComboBox ID="cmbEmpresa" runat="server" Mode="Local" ValueField="Codigo" DisplayField="Fantaisa"
    Editable="false" FieldLabel="Empresa" LazyInit="false" LoadingText="Carregando..."
    ForceSelection="true">
    <Store>
    <ext:Store ID="dsEmpresasMasterPage" runat="server" WarningOnDirty="false">
    <Proxy>
    <ext:PageProxy Url="/athenasx/Empresa/ObterListaEmpresasPermitidas/" />
    </Proxy>
    <Model>
    <ext:Model runat="server">
    <Fields>
    <ext:ModelField Name="Fantaisa" />
    <ext:ModelField Name="Codigo" />
    </Fields>
    </ext:Model>
    </Model>
    </ext:Store>
    </Store>
    <Items>
    <ext:ListItem Text="Todas as Empresas" Value="0" />
    </Items>
    <SelectedItem Value="0" />
    <Listeners>
    <Select Handler="FiltrarFiliaisEmpresa();" />
    </Listeners>
    <DirectEvents>
    <Select Url="/athenasx/Empresa/SelecionarEmpresa">
    <ExtraParams>
    <ext:Parameter Name="codigoempresa" Value="Ext.encode(#{cmbEmpresa}.getValue())"
    Mode="Raw" />
    </ExtraParams>
    </Select>
    </DirectEvents>
    </ext:ComboBox>
    After code:

    <ext:ComboBox ID="cmbEmpresa" runat="server" ValueField="Codigo" DisplayField="Fantaisa"
    Editable="false" FieldLabel="Empresa">
    <Store>
    <ext:Store ID="dsEmpresasMasterPage" runat="server" WarningOnDirty="false">
    <Proxy>
    <ext:AjaxProxy Url="/athenasx/Empresa/ObterListaEmpresasPermitidas/" />
    </Proxy>
    <Model>
    <ext:Model runat="server">
    <Fields>
    <ext:ModelField Name="Fantaisa" />
    <ext:ModelField Name="Codigo" />
    </Fields>
    </ext:Model>
    </Model>
    </ext:Store>
    </Store>
    <Items>
    <ext:ListItem Text="Todas as Empresas" Value="0" />
    </Items>
    <Listeners>
    <Select Handler="FiltrarFiliaisEmpresa();" />
    </Listeners>
    <DirectEvents>
    <Select Url="/athenasx/Empresa/SelecionarEmpresa">
    <ExtraParams>
    <ext:Parameter Name="codigoempresa" Value="Ext.encode(#{cmbEmpresa}.getValue())"
    Mode="Raw" />
    </ExtraParams>
    </Select>
    </DirectEvents>
    </ext:ComboBox>
    Last edited by Daniil; May 10, 2012 at 8:33 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I'm a bit confused. What a start point do you migrate from? Ext.NET v1?

    Well, there were no Model, ModelField.

    Also there is "PageProxy" with Url in "Before code" and "AjaxProxy" in "After code". It confuses as well.

    Also, ComboBox Items and Store should not be used at the same time.

    Please clarify what exactly issue are you facing at the moment?
  3. #3
    Hi, We have migrated from version 1.3 to version 2.0.
    The combobox was completed as follows:

    <ext:ComboBox ID="cmbEmpresa" runat="server" Mode="Local" ValueField="Codigo" DisplayField="Fantaisa"
                    Editable="false" FieldLabel="Empresa" LazyInit="false" LoadingText="Carregando..."
                    ForceSelection="true">
                    <Store>
                        <ext:Store ID="dsEmpresasMasterPage" runat="server" WarningOnDirty="false">
                            <Proxy>
                                <ext:HttpProxy Url="/athenasx/Empresa/ObterListaEmpresasPermitidas/" />
                            </Proxy>
                            <Reader>
                                <ext:JsonReader Root="data">
                                    <Fields>
                                        <ext:RecordField Name="Fantaisa" />
                                        <ext:RecordField Name="Codigo" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                    <Items>
                        <ext:ListItem Text="Todas as Empresas" Value="0" />
                    </Items>
                    <SelectedItem Value="0" />
                    <Listeners>
                        <Select Handler="FiltrarFiliaisEmpresa();" />
                    </Listeners>
                    <DirectEvents>
                        <Select Url="/athenasx/Empresa/SelecionarEmpresa">
                            <ExtraParams>
                                <ext:Parameter Name="codigoempresa" Value="Ext.encode(#{cmbEmpresa}.getValue())"
                                    Mode="Raw" />
                            </ExtraParams>
                        </Select>
                    </DirectEvents>
                </ext:ComboBox>
    After the migration, ext: HttpProxy no longer exists and changed to ext: AjaxProxy. But the combobox returns no value after the migration. Thereby:

    <ext:ComboBox ID="cmbEmpresa" runat="server" ValueField="Codigo" DisplayField="Fantaisa"
                    Editable="false" FieldLabel="Empresa">
                    <Store>
                        <ext:Store ID="dsEmpresasMasterPage" runat="server" WarningOnDirty="false">
                            <Proxy>
                                <ext:AjaxProxy Url="/athenasx/Empresa/ObterListaEmpresasPermitidas/" />
                            </Proxy>
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="Fantaisa" />
                                        <ext:ModelField Name="Codigo" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <Items>
                        <ext:ListItem Text="Todas as Empresas" Value="0" />
                    </Items>
                    <Listeners>
                        <Select Handler="FiltrarFiliaisEmpresa();" />
                    </Listeners>
                    <DirectEvents>
                        <Select Url="/athenasx/Empresa/SelecionarEmpresa">
                            <ExtraParams>
                                <ext:Parameter Name="codigoempresa" Value="Ext.encode(#{cmbEmpresa}.getValue())"
                                    Mode="Raw" />
                            </ExtraParams>
                        </Select>
                    </DirectEvents>
                </ext:ComboBox>



    Quote Originally Posted by Daniil View Post
    Hi,

    I'm a bit confused. What a start point do you migrate from? Ext.NET v1?

    Well, there were no Model, ModelField.

    Also there is "PageProxy" with Url in "Before code" and "AjaxProxy" in "After code". It confuses as well.

    Also, ComboBox Items and Store should not be used at the same time.

    Please clarify what exactly issue are you facing at the moment?
  4. #4
    You should set up Reader for the AjaxProxy.

    Example
    <ext:AjaxProxy Url="url">
        <Reader>
            <ext:JsonReader Root="data" />
        </Reader>
    </ext:AjaxProxy>
  5. #5
    The code was as follows, but does not work:

    <ext:ComboBox ID="cmbEmpresa" runat="server" ValueField="Codigo" DisplayField="Fantaisa"
                    Editable="false" FieldLabel="Empresa">
                    <Store>
                        <ext:Store ID="dsEmpresasMasterPage" runat="server" WarningOnDirty="false">
                            <Proxy>
                                <ext:AjaxProxy Url="/athenasx/Empresa/ObterListaEmpresasPermitidas/">
                                    <Reader>
                                        <ext:JsonReader Root="data" />
                                    </Reader>
                                </ext:AjaxProxy>
                            </Proxy>
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="Fantaisa" />
                                        <ext:ModelField Name="Codigo" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <Items>
                        <ext:ListItem Text="Todas as Empresas" Value="0" />
                    </Items>
                    <Listeners>
                        <Select Handler="FiltrarFiliaisEmpresa();" />
                    </Listeners>
                    <DirectEvents>
                        <Select Url="/athenasx/Empresa/SelecionarEmpresa">
                            <ExtraParams>
                                <ext:Parameter Name="codigoempresa" Value="Ext.encode(#{cmbEmpresa}.getValue())"
                                    Mode="Raw" />
                            </ExtraParams>
                        </Select>
                    </DirectEvents>
                </ext:ComboBox>
    Quote Originally Posted by Daniil View Post
    You should set up Reader for the AjaxProxy.

    Example
    <ext:AjaxProxy Url="url">
        <Reader>
            <ext:JsonReader Root="data" />
        </Reader>
    </ext:AjaxProxy>
  6. #6
    Does a request to AjaxProxy Url occur? What is a response?

    Is there any error, exception?

    Please try to remove ComboBox Items.
  7. #7
    Follows the code of the url:

    public AjaxResult ObterListaEmpresasPermitidas()
            {
               var retorno = new List<Empresa>();
    
                retorno = this.Repositorios.Empresa.ListaEmpresasUsuarioCorrente(0).ToList();
    
                return new AjaxResult(retorno);
            }
    The values ​​are returned correctly and returns no error.

    The items were removed from the combobox, but the problem continues.

    Quote Originally Posted by Daniil View Post
    Does a request to AjaxProxy Url occur? What is a response?

    Is there any error, exception?

    Please try to remove ComboBox Items.
  8. #8
    You have to use JsonResult instead AjaxResult and Root="Data" is not required in your case
    If it doesn't help then please post response text for request to ObterListaEmpresasPermitidas action
  9. #9
    The controller code was as follows:

    public JsonResult ObterListaEmpresasPermitidas()
            {
                var retorno = new List<Empresa>();
    
                retorno = this.Repositorios.Empresa.ListaEmpresasUsuarioCorrente(0).ToList();// zero quer dizer provisóriamente todas as empresas
    
                return new JsonResult();
            }
    The code for the combobox was as follows:

    <ext:ComboBox ID="cmbEmpresa" runat="server" ValueField="Codigo" DisplayField="Fantaisa"
                    Editable="false" FieldLabel="Empresa">
                    <Store>
                        <ext:Store ID="dsEmpresasMasterPage" runat="server" WarningOnDirty="false">
                            <Proxy>
                                <ext:AjaxProxy Url="/athenasx/Empresa/ObterListaEmpresasPermitidas/">
                                    <Reader>
                                        <ext:JsonReader />
                                    </Reader>
                                </ext:AjaxProxy>
                            </Proxy>
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="Fantaisa" />
                                        <ext:ModelField Name="Codigo" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <Listeners>
                        <Select Handler="FiltrarFiliaisEmpresa();" />
                    </Listeners>
                    <DirectEvents>
                        <Select Url="/athenasx/Empresa/SelecionarEmpresa">
                            <ExtraParams>
                                <ext:Parameter Name="codigoempresa" Value="Ext.encode(#{cmbEmpresa}.getValue())"
                                    Mode="Raw" />
                            </ExtraParams>
                        </Select>
                    </DirectEvents>
                </ext:ComboBox>
    But it returns no records and still has the following error:

    This request has Been blocked because sensitive information Could Be Disclosed to third party web sites When this is used in a GET request. To allow GET requests, set to JsonRequestBehavior AllowGet.


    Quote Originally Posted by Vladimir View Post
    You have to use JsonResult instead AjaxResult and Root="Data" is not required in your case
    If it doesn't help then please post response text for request to ObterListaEmpresasPermitidas action
    Last edited by Daniil; May 09, 2012 at 8:14 PM. Reason: Please use [CODE] tags
  10. #10
    Use POST method for Ajaxproxy (<ActionMethods Read="POST" />) or pass 'JsonRequestBehavior.AllowGet' as second argument of JsonResult
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Update TextField by Ajax Combobox
    By Oliver in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 30, 2012, 12:30 AM
  2. [CLOSED] [1.0] MVC AjaxResult
    By alliedwallet.com in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 21, 2011, 8:07 AM
  3. AjaxResult class issue in ext.net.dll
    By vs.mukesh in forum 1.x Help
    Replies: 4
    Last Post: Jun 10, 2010, 1:38 PM
  4. [CLOSED] AjaxResult and AjaxStoreResult
    By fondant in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 19, 2009, 7:45 PM
  5. [CLOSED] SVN Update + Combobox changed
    By reinout.mechant@imprss.be in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jul 27, 2009, 3:59 PM

Posting Permissions