[CLOSED] Dynamic columns for data view

  1. #1

    [CLOSED] Dynamic columns for data view

    Hi All,

    I am trying to create a page based on the example below but with dynamic columns.

    https://examples2.ext.net/#/DataView/Advanced/Report/

    I don't know amount of columns it will come from the server. As far I can understand it could be done like this:

    <ext:DataView runat="server" DisableSelection="true" ItemSelector="td.letter-row" EmptyText="No data to display">
    <Store>
     <ext:Store ID="dsReport" runat="server">
       <Model>
        <ext:Model runat="server">
          <Fields>
            <ext:ModelField Name="header" IsComplex="true" />
            <ext:ModelField Name="data" IsComplex="true" />
          </Fields>
        </ext:Model>
       </Model>
     </ext:Store>
    </Store>
    <Tpl ID="Template1" runat="server">
      <Html>
        <p>Customer Address Book</p>                                                                        
        <table>
          <tpl for=".">                        
            <tr>
              <tpl for="header">
                <th>{headerName}</th>
              </tpl>
            </tr>
          </tpl>
    
          <tpl for=".">
            <tr>
              <td class="letter-row" colspan="6">
                <div><h2 class="letter-selector">{Letter}</h2></div>
                <tpl for="data">
                <table>                                                
                  <tr class="customer-record">
                  <td class="cust-name" custID="{CustomerID}" custName="{CompanyName}" email="{Email}" style="width:10%">{ContactName}</td>
                  <td style="width:18%">&nbsp;{Address}</td>
                  <td style="width:18%">&nbsp;{City}</td>
                  <td style="width:18%">&nbsp;{Region}</td>
                  <td style="width:18%">&nbsp;{PostalCode}</td>
                  <td style="width:18%">&nbsp;{Country}</td>
                </tr>
                </table>
                </tpl>
              </td>
            </tr>                                
          </tpl>                    
        </table>
      </Html>
    </Tpl>
    </ext:DataView>
    However, I do not want to use complex fields to define a data, because in this case I will lose standard store sorting abilities. I would prefer to define header and data in different stores or at least, header can be defined separately in array, I just need only to know how to tell xtemplate to use separate data sources for header and data.

    Thanks,
    Alexander
    Last edited by Daniil; Apr 04, 2013 at 4:25 AM. Reason: [CLOSED]
  2. #2
    Hi Alexander,

    I just need only to know how to tell xtemplate to use separate data sources for header and data.
    Well, internally an XTemplate doesn't uses a Store at all. It just needs some data. So, a DataView passed a Store's data to its template.

    A DataView can't use a few Stores.

    So, the possible solutions are:

    1. Using two separate DataViews for a header and a body.

    2. Do not use a DataView at all and to program with Stores and XTemplates only. It this case you are loosing a DataView's capabilities. So, I would prefer the first way.

    3. Advanced. Overriding the collectData method.
    http://docs.sencha.com/ext-js/4-2/so...od-collectData
    Last edited by Daniil; Apr 01, 2013 at 6:01 AM.

Similar Threads

  1. [CLOSED] persisting the customized columns in Razor view
    By gets_gui in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 08, 2013, 3:07 PM
  2. Replies: 2
    Last Post: Aug 22, 2012, 4:03 PM
  3. [CLOSED] put a data view inside a data view,
    By farisqadadeh in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: Mar 14, 2011, 7:58 PM
  4. NaN/NaN/0NaN in some of the Grid View columns
    By meareal in forum 1.x Help
    Replies: 3
    Last Post: Jan 31, 2011, 2:03 PM
  5. [CLOSED] GridPanel with dynamic columns lost values after reload data
    By asztern in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 21, 2010, 9:22 AM

Posting Permissions