Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript - How to add objects to column array in kendo ui grid dynamically?
    primarykey
    data
    text
    <p>I am trying to generate objects in the columns array as the heading implies, although I haven't found a working method. </p> <pre><code>alert( "Value 1: " + temporaryArray[1] + " - " + finalArray[1].values ); alert( "Value 2: " + temporaryArray[2] + " - " + finalArray[2].values ); var myGrid = $("#grid").kendoGrid( { columns: [ { title: temporaryArray[0] + " ", field: gridArray[0].values + " " } ], dataSource: { data:finalArray, pageSize:10 }, scrollable:false, pageable:true }); </code></pre> <p>I've tried the following to add the object:</p> <pre><code>for( var x = 0; x &lt; finalArray.length; x++ ) { myGrid[columns] = { temporaryArray[x]:finalArray[x] }; } </code></pre> <p><em>And</em></p> <pre><code>for( var x = 0; x &lt; finalArray.length; x++ ) { myGrid.columns[values]= finalArray[x].values; } </code></pre> <p><strong>with no success...</strong></p> <p>The following looks like an array of objects inside of the object which I want to achieve dynamically:</p> <pre><code>columns: [ { title: temporaryArray[0] + " ", field: gridArray[0].values + " " }, { title: temporaryArray[1] + " ", field: gridArray[1].values + " " }, { title: temporaryArray[2] + " ", field: gridArray[2].values + " " } ], </code></pre> <p><em>For example:</em></p> <pre><code>for( var x = 0; x &lt; finalArray.length; x++ ) { myGrid[columns] = { temporaryArray[x]:finalArray[x] }; } </code></pre> <p><em>I want to generate the objects using a for loop to generate an array of objects inside the column array.</em></p> <p>What I want to know is, whether this is possible to do dynamically? or just possible at all without hard coding it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload