JavaScript Creating table from json creating table from another table,creating table from another table

I have this table

<table class="table">
    <tr>
    <td ng-repeat="(k, obj) in items | orderBy:'key'">{{obj.key}}</td>
  </tr>
</table>

That shows a table of only one row with all the items in the json ($scope.items) ordered alphabetically by the key value.

Is there any way to make it so that it has a fixed number of columns, more than one row and keeps being sorted by the key value?

Answer:1

You need the parent index and slice up array put a tr every X times

<table class="table">
  <tr ng-repeat="trs in items" ng-if="$index % howMany == 0" ng-init="pIdx=$index">
     <td ng-repeat="(k, obj) in items.slice(pIdx,pIdx+howMany) | orderBy:'key'">{{obj.key}}</td>
  </tr>
</table>

In this example declare a variable var howMany = 6 so it will have 6 tds every row.

Answer:2

Try this fiddle to get yourself started

https://jsfiddle.net/U3pVM/17932/

<table class="table" ng-controller="tstCtrl">
    <tr ng-repeat="(k, obj) in items | orderBy:'key'">
        <td>{{k}}</td>
        <td>{{obj.name}}</td>
        <td>{{obj.type}}</td>
  </tr>
</table>

The short answer is yes. You need to change how you are using ng-repeat. It does not repeat the tag it is contained within, only the tags inside the ng-repeat tag.

Answer:3

This will show a fixed number of columns and remain sorted.

<table class="table">
  <tr>
    <th>Key</th>
    <th>Other Property</th>
  </tr>
  <tr ng-repeat="(k, obj) in items | orderBy:'key'">
    <td>{{obj.key}}</td>
    <td>{{obj.otherProperty}}</td>
  </tr>
</table>
Answer:4

I have quite a challenge here, and my language gap could also provide a challenge to you decrypting the title, but, heh... http://toms.somese.lv/test/ or http://jsfiddle.net/Wm32D/1/ (created by gvee)...

I have quite a challenge here, and my language gap could also provide a challenge to you decrypting the title, but, heh... http://toms.somese.lv/test/ or http://jsfiddle.net/Wm32D/1/ (created by gvee)...

This is the method I have used to bind remote data to ListView based on the date. function getListData(date) { $.ajax({ type: "POST", url: wcfurl + "getList", data: '{"...

This is the method I have used to bind remote data to ListView based on the date. function getListData(date) { $.ajax({ type: "POST", url: wcfurl + "getList", data: '{"...

  1. change datasource kendo grid
  2. change datasource kendo dropdownlist
  3. change datasource kendo
  4. kendo datasource change
  5. change data in datasource kendo
  6. kendo change datasource dynamically
  7. datasource change event in kendo grid
  8. kendo change datasource url

I have a site that utilizes the Bootstrap 3 navbar. It is positioned 280px below a block div and sticks to the top of the page when scrolled to that point HTML ( in < head > tags ) <script>...

I have a site that utilizes the Bootstrap 3 navbar. It is positioned 280px below a block div and sticks to the top of the page when scrolled to that point HTML ( in < head > tags ) <script>...

Here's my predicament. In my JSP, I am trying to upload a file which in turns goes to a JS function. In my JS function, a dynamic iframe is being created, and has an onload function. The onload ...

Here's my predicament. In my JSP, I am trying to upload a file which in turns goes to a JS function. In my JS function, a dynamic iframe is being created, and has an onload function. The onload ...