[CLOSED] Mapping gridpanel to complex store

  1. #1

    [CLOSED] Mapping gridpanel to complex store

    Hi guys, i have the following JSON: http://paste2.org/p/2511356 (It's long so i posted there...)

    I'm mapping it to a Store like this:
    <tlf:Storage AutoLoad="false" ID="storeTelecontrolEventos" runat="server">
            <Proxy>
                <ext:HttpProxy Method="GET" Json="true" Url="TelecontrolHandler.ashx" />
            </Proxy>
            <BaseParams>
                <ext:Parameter Name="Operation" Value="GetEventos" Mode="Value" />
            </BaseParams>
            <Reader>
                <ext:JsonReader Root="telecontrol.Eventos">
                    <Fields>
                        <ext:RecordField Name="IdTelecontrolEvento" Type="Int" />
                        <ext:RecordField Name="IdTelecontrolCabecera" Type="Int" />
                        <ext:RecordField Name="Senal" Mapping="Senal.Nombre" />
                        <ext:RecordField Name="Fecha" Type="Date" />
                        <ext:RecordField Name="HoraEmision" />
                        <ext:RecordField Name="FechaEmision" Type="Date" />
                        <ext:RecordField Name="TipoEventoTelecontrol"  Mapping="TipoEventoTelecontrol.Nombre" />
                        <ext:RecordField Name="Programa" Mapping="Programa.Nombre" />
                        <ext:RecordField Name="Variante" Mapping="Variante.Nombre" />
                        <ext:RecordField Name="NroBloque" Type="Int" />
                        <ext:RecordField Name="OrdenEnBloque" Type="Int"/>
                        <ext:RecordField Name="Material" Mapping="Material.NumeroYNombre" />
                        <ext:RecordField Name="Duracion" Type="Int" />
                        <ext:RecordField Name="Producto" Mapping="Producto.Nombre" />
                        <ext:RecordField Name="Anunciante" Mapping="Anunciante.RazonSocial" />
                        <ext:RecordField Name="Orden" Mapping="IdOrden" />
                        <ext:RecordField Name="Observaciones" />
                        <ext:RecordField Name="Telecontrolado" />
                        <ext:RecordField Name="IdSchedulerEvento" Type="Int" />
                        <ext:RecordField Name="IdNovedadAsRun" Type="Int" />
                        <ext:RecordField Name="IdNovedadMonitor" Type="Int" />
                        <ext:RecordField Name="IdResultadoTelecontrol" Type="Int" />
                        <ext:RecordField Name="FechaAlta" Type="Date" />
                        <ext:RecordField Name="FechaModif" Type="Date" />
                        <ext:RecordField Name="UsuarioAlta" />
                        <ext:RecordField Name="UsuarioModif" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <BaseParams>
                <ext:Parameter Name="Operation" Value="GetEventos" Mode="Value" />
                <ext:Parameter Name="IdTelecontrol" Value="0" Mode="Value" />
            </BaseParams>
            <Listeners>
                <BeforeLoad Fn="function (store, operation, opts) {
            var telecontrolCabecera = #{storeTelecontrolCabecera}.getAllRange()[0];
            var idTelecontrol = 0;
            if (telecontrolCabecera!=null) 
            {
                idTelecontrol = telecontrolCabecera.json.Cabecera.IdTelecontrol; 
    
            }
            Ext.apply(operation, {
                params: {
                    Operation: 'GetEventos',
                    IdTelecontrol: idTelecontrol
                }
           });
    }" />
            </Listeners>
        </tlf:Storage>
    The problem is that when it loads, it fails because the field "Programa" is null, so it can't map it.
    I want to be able to show the grid anyways.

    Also, i have a grid and i want to map it to the store.
    If i set recordfield as complex (leaving only "Producto" as the name with no mapping), the DataIndex of the column should be "Producto.Nombre" ?
    How can i map a gridpanel to a complex mapped stored?
    Last edited by Daniil; Nov 28, 2012 at 2:08 PM. Reason: [CLOSED]
  2. #2
    Hi @tlfdesarrollo,

    Please take a look at this example.
    https://examples1.ext.net/#/GridPane.../Data_Prepare/
  3. #3
    Nice, i missed that example.

    Only using a convert function or a renderer function is the only way to achieve this?

    just asking.

    I'll be using this right now =)
  4. #4
    Quote Originally Posted by Daniil View Post
    Hi @tlfdesarrollo,

    Please take a look at this example.
    https://examples1.ext.net/#/GridPane.../Data_Prepare/
    Almost solved using this code =)
                        <ext:RecordField Name="Producto">
                            <Convert Handler="var parentFieldName=this.name;if (value!=null) { Ext.iterate(value, function(prop) { record[parentFieldName + '_' + prop] = value[prop];});};return value;" />
                        </ext:RecordField>
  5. #5
    Good. Please clarify do you need any further assistance in this thread?

Similar Threads

  1. [CLOSED] Bug in Store Mapping
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 30, 2011, 11:05 AM
  2. Datatable and Store columns mapping
    By QualityCode in forum 1.x Help
    Replies: 0
    Last Post: Dec 16, 2010, 8:45 PM
  3. store and complex key
    By maxdiable in forum 1.x Help
    Replies: 1
    Last Post: Nov 26, 2010, 6:46 PM
  4. Replies: 4
    Last Post: Feb 02, 2010, 1:00 PM
  5. mapping more complex objects to a Store
    By principal_X in forum 1.x Help
    Replies: 2
    Last Post: Jan 26, 2009, 6:16 PM

Posting Permissions