KendoGrid/Angular: Unable to dynamically create grid columns/data


ps0604

In this sprite, I have an empty grid (no columns). When I click on "Build Grid" I need to add columns (taken from an array) and add a row to the table.

The problem is that the columns are not added to the grid, any ideas? If I try to refresh the grid, I get undefinedan error.

HTML:

<button ng-click="buildGrid()">Build Grid</button>
<div kendo-grid="grid" k-options="gridOptions" k-data-source="ds"></div>

Javascript:

var app = angular.module("app", [ "kendo.directives" ]);

function MyCtrl($scope) {

    $scope.ds = []

    $scope.colsList =  [{ name: "col1" },
                        { name: "col2" },
                        { name: "col3" },
                        { name: "col4" }];


  var gridCols = [];

    $scope.gridOptions = {
            columns: gridCols
  };


$scope.buildGrid = function() {

        $scope.data = {};

        for (var x=0;x<$scope.colsList.length;x++) {
            var col = {};
            col.field = $scope.colsList[x].name;
            col.title = $scope.colsList[x].name;
            $scope.data[col.field] = "" + (1111 * (x+1));
            gridCols.push(col);
        }

        // add one row to the table
        $scope.ds.push($scope.data);
        //$scope.grid.refresh();

    };  
}
Lars Höppner

You need to use k-rebind in order for the grid to reinitialize (you can't dynamically set columns on an existing grid):

<div kendo-grid="grid" 
     k-options="gridOptions" 
     k-data-source="ds" 
     k-rebind="gridOptions"></div>

( demo )

Related


KendoGrid/Angular: Unable to dynamically create grid columns/data

ps0604 In this sprite, I have an empty grid (no columns). When I click on "Build Grid" I need to add columns (taken from an array) and add a row to the table. The problem is that the columns are not added to the grid, any ideas? If you try to refresh the grid,

KendoGrid/Angular: Unable to dynamically create grid columns/data

ps0604 In this sprite, I have an empty grid (no columns). When I click on "Build Grid" I need to add columns (taken from an array) and add a row to the table. The problem is that the columns are not added to the grid, any ideas? If you try to refresh the grid,

Dynamically create Bootstrap grid

Swopnilnep I'm trying to dynamically generate bootstrap columns using a javascript function. The purpose is to make them appear as different columns in the same row. It currently looks like this: I call this function on window.onload() with the div id: // Upda

Dynamically create Bootstrap grid

Swopnilnep I'm trying to dynamically generate bootstrap columns using a javascript function. The purpose is to make them appear as different columns in the same row. It currently looks like this: I call this function on window.onload() with the div id: // Upda

Dynamically create Bootstrap grid

Swopnilnep I'm trying to dynamically generate bootstrap columns using a javascript function. The purpose is to make them appear as different columns in the same row. It currently looks like this: I call this function on window.onload() with the div id: // Upda

Dynamically create Bootstrap grid

Swopnilnep I'm trying to dynamically generate bootstrap columns using a javascript function. The purpose is to make them appear as different columns in the same row. It currently looks like this: I call this function on window.onload() with the div id: // Upda

How to create a grid dynamically in unity

Samsung My vertices have color values. I want to make a mesh using vertices with the same color value. This photo is an example. I took a picture with an android phone and did an image segmentation of the object So I get a color value corresponding to the coor

How to create a dynamically changing grid?

Uncle Bear What I'm trying to say at the beginning is that I'm just starting my adventures with Xaml, so please understand if the question is trivial. I'm going to design a user control with variable layout, which is controlled by radio buttons in a UWP - C++C

Java dynamically create button in grid

Hassett I am creating a desktop application in Java in which I want to create buttons dynamically. Dynamically created buttons should be placed in a grid-like structure. Now, my concern is, if I want to access these buttons, what should I do since I don't have

Java dynamically create button in grid

Hassett I am creating a desktop application in Java in which I want to create buttons dynamically. Dynamically created buttons should be placed in a grid-like structure. Now, my concern is, if I want to access these buttons, what should I do since I don't have

Unable to dynamically create div content

user7461846 What's the problem here? var str = " <div class='lorem'>lorem</div> <br> <div class='ipsum'>ipsum</div> "; $('.parent').html(str); .parent{ width:50%; margin:14px auto; background:#eee; } .lorem{ cursor:cell; background:gold; } .ipsum{ cursor:ce

Unable to dynamically create table in MySQL

username I am following a model view control approach to create an application. I am trying to dynamically create a table when the page is loaded. Here is the code. existdashboard.php <?php require_once ("controller/db-config.php"); require_once ("contro

React.js - Dynamically create grid with HTML

Alejandro Currently, I'm working on an FCC project called "The Game of Life" Before starting, I was simply working on how to render the grid onto the page. I want to be able to change the dimensions of the table while still staying in the container the table i

Dynamically create grid layout with div tags in PHP

David Diaz So I had a similar problem to one , but I only applied it in vanilla PHP, not WordPress. After countless hours of struggle, I finally found the answer, but if I increase the size of the grid number, the items won't align. I want it to look like this

Dynamically create grid for Angular in Kendo UI

ps0604 Kendo UI for Angular has a grid that can be defined as follows: <kendo-grid [data]="gridData" [height]="410"> <kendo-grid-column field="ProductID" title="ID" width="40"> </kendo-grid-column> <kendo-grid-column field="

Dynamically create grid for Angular in Kendo UI

ps0604 Kendo UI for Angular has a grid that can be defined as follows: <kendo-grid [data]="gridData" [height]="410"> <kendo-grid-column field="ProductID" title="ID" width="40"> </kendo-grid-column> <kendo-grid-column field="

React.js - Dynamically create grid with HTML

Alejandro Currently, I'm working on an FCC project called "The Game of Life" Before starting, I was simply working on how to render the grid onto the page. I want to be able to change the dimensions of the table while still staying in the container the table i

React.js - Dynamically create grid with HTML

Alejandro Currently, I'm working on an FCC project called "The Game of Life" Before starting, I was simply working on how to render the grid onto the page. I want to be able to change the dimensions of the table while still staying in the container the table i

Dynamically create grid in Xamarin.Forms

Don Joe I'm currently testing the app to list products, but I'm having an issue where the grid cannot be dynamically generated with the corresponding content (only for labels at the moment). I want to generate them as soon as the main page is called. I've gone

Dynamically create grid layout with div tags in PHP

David Diaz So I had a similar problem to one , but I only applied it in vanilla PHP, not WordPress. After countless hours of struggle, I finally found the answer, but if I increase the size of the grid number, the items won't align. I want it to look like this

Dynamically create grid layout with div tags in PHP

David Diaz So I had a similar problem to one , but I only applied it in vanilla PHP, not WordPress. After countless hours of struggle, I finally found the answer, but if I increase the size of the grid number, the items won't align. I want it to look like this

Dynamically create grid layout with div tags in PHP

David Diaz So I had a similar problem to one , but I only applied it in vanilla PHP, not WordPress. After countless hours of struggle, I finally found the answer, but if I increase the size of the grid number, the items won't align. I want it to look like this

Dynamically create kendo grid columns in angular controller

Kevin I'm trying to dynamically build the structure of a kendo corner mesh. My problem is that the grid options are not known when the k-optionsproperty is evaluated , so the grid will be bound to all columns on the data source. Here is the HTML: <div kendo-gr

React.js - Dynamically create grid with HTML

Alejandro Currently, I'm working on an FCC project called "The Game of Life" Before starting, I was simply working on how to render the grid onto the page. I want to be able to change the dimensions of the table while still staying in the container the table i

React.js - Dynamically create grid with HTML

Alejandro Currently, I'm working on an FCC project called "The Game of Life" Before starting, I was simply working on how to render the grid onto the page. I want to be able to change the dimensions of the table while still staying in the container the table i