Show only one element of each list in html

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gundogduyakici
    Senior Member
    • Mar 2018
    • 165

    Show only one element of each list in html

    Each list I want to select and display only one value in the loop. How can I do that ? I will show you sample codes.If there's a place you do not understand, ask.

    Thanks in advance for your help.


    Code:
    <ul class="list-group">
       {{#each rowList}}
       <li data-id="{{./this}}" class="list-group-item list-row">
            {{{var this.ExampleCityName ../this}}}
       </li>
       {{/each}}
    </ul>
    Last edited by gundogduyakici; 04-15-2018, 09:14 PM.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    You can check the index

    Comment

    • gundogduyakici
      Senior Member
      • Mar 2018
      • 165

      #3
      I didn't understand. Could you give me more information? tanya

      Comment

      • gundogduyakici
        Senior Member
        • Mar 2018
        • 165

        #4
        Code:
        return Dep.extend({
        name: 'MyCareerGoal',
        _template: '<div class="list-container">{{{list}}}</div>',
        
        defaultListLayout: {
        rows: [
              [
                  {
                              name: 'entityType'
                   },
                   {
                              name: 'calculationType'
                   },
                   {
                              name: 'calculationValue'
                   },
                   {
                              name: 'queryType'
                    }
              ]
        ]
        },
        init: function () {
                Dep.prototype.init.call(this);
        },
        setup: function () {
             this.seeds = {};
             this.scopeList = this.getOption('enabledScopeList') || [];
             this.listLayout = {};
             this.scopeList.forEach(function (item) {
             this.listLayout[item] = this.defaultListLayout;
        }, this);
        this.wait(true);
        var i = 0;
        this.scopeList.forEach(function (scope) {
             this.getModelFactory().getSeed(scope, function (seed) {
                  this.seeds[scope] = seed;
                  i++;
                  if (i == this.scopeList.length) {
                       this.wait(false);
                  }
        }.bind(this));
        }, this);
        },
        afterRender: function () {
                     this.collection = new MultiCollection();
                     this.collection.seeds = this.seeds;
                     this.collection.url = 'CareerSteps/action/myCareerGoal';
                     this.collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5;
                     this.collection.data.entityTypeList = this.scopeList;
                     this.listenToOnce(this.collection, 'sync', function () {
                     this.createView('list', 'views/record/list-expanded', {
                           el: this.options.el + ' > .list-container',
                           pagination: false,
                           type: 'list',
                           checkboxes: false,
                           collection: this.collection,
                           listLayout: this.listLayout,
                     }, function (view) {
                     view.render();
        });
        }, this);
        this.collection.fetch();
        },
        actionRefresh: function () {
                 this.collection.fetch();
        }

        I want this;

        Code:
        <ul class="list-group">
        {{#each rowList}}
             <li data-id="{{./this}}" class="list-group-item list-row">
                  {{{var this.entityType <----- like that ? ../this}}}
              </li>
        {{/each}}
        </ul>
        Last edited by gundogduyakici; 04-16-2018, 08:49 AM.

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          It would be really nice to have access to the index of an each iteration. There are ready-to-use block helpers out there, but having this upstream would be nice. I can provide a pull request if tha...

          Comment

          • gundogduyakici
            Senior Member
            • Mar 2018
            • 165

            #6
            I did what you said, but only the ID is coming. How do I get the data I want?

            Result;

            Code:
            <ul class="list-group">
                 {{#each rowList}}
                      <li data-id="{{./this}}" class="list-group-item list-row">
                           {{@index}}: {{this}}
                      </li>
                  {{/each}}
            </ul>
            I want this ;

            Code:
            <ul class="list-group">
                 {{#each rowList}}
                      <li data-id="{{./this}}" class="list-group-item list-row">
                           {{@index}}: {{this.cityName}}
                      </li>
                  {{/each}}
            </ul>
            Because I use my own design.

            Comment

            • gundogduyakici
              Senior Member
              • Mar 2018
              • 165

              #7
              Know what I mean ? tanya

              Comment

              • gundogduyakici
                Senior Member
                • Mar 2018
                • 165

                #8
                I want to use what I need from the returning values tanya
                Last edited by gundogduyakici; 04-17-2018, 01:08 PM.

                Comment

                • gundogduyakici
                  Senior Member
                  • Mar 2018
                  • 165

                  #9
                  Code:
                  <ul class="list-group">    
                     {{#each rowList}}          
                       <li data-id="{{./this}}" class="list-group-item list-row">              
                           <h2>City: </h2>{{cityName}}              
                           <h2>Car: </h2> {{carName}}          
                       </li>    
                     {{/each}}
                  </ul>

                  Comment

                  Working...