Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript - Dynamic number of rows giving an error
    primarykey
    data
    text
    <p>I have previously posted a question about this code to <a href="https://stackoverflow.com/q/15779973/2236074">generate a kendo grid dynamically</a>.</p> <p>The current problem I have now, even when I hardcode the number of columns like so:</p> <pre><code>var numberOfRows = 2; var numberOfColumns = 12; var columnsPerRow = numberOfColumns/numberOfRows; </code></pre> <p>Is that I get the error :</p> <p><img src="https://i.stack.imgur.com/UStB2.png" alt="enter image description here"></p> <pre><code>First of all, what does this mean? </code></pre> <p>The columnsPerRow is used like so:</p> <pre><code>var columnDefs = []; counter = 0; var arrayData = []; for( var x = 0; x &lt; result.length-1; x=x+Math.floor(columnsPerRow)+1 ) { var tempArr = new Array(); for( var y = 0; y &lt; columnsPerRow; y++ ) { var num = x + y; tempArr.push(result[num]); } arrayData.push(tempArr); } var dataTitles = []; for( var x = 0; x &lt; titleArray.length; x++ ) { var head = ""; head = titleArray[x]; head = head.replace(/ /g,""); dataTitles.push(head); } var counter = 0; var columnDefs = []; for (var i = 0; i &lt; columnsPerRow.length; i++) { if (counter == (columnsPerRow - 1)) { counter = 0; } columnDefs.push({ field: dataTitles[counter], template: result[i].value }); counter++; } </code></pre> <p>The grid is displayed as so:</p> <p><img src="https://i.stack.imgur.com/qVaPw.png" alt="enter image description here"></p> <p>and when I hide the column variables like so:</p> <pre><code>/*var numberOfRows = 2; var numberOfColumns = 12; var columnsPerRow = numberOfColumns/numberOfRows;*/ </code></pre> <p>the output looks as it's supposed to:</p> <p><img src="https://i.stack.imgur.com/wuwnK.png" alt="enter image description here"></p> <p>but then null values are used for the number of columns, thus the for loop does not loop.</p> <p>Except that the grid does not display the data.</p> <p>I have placed all my javascript and html in this <a href="http://jsfiddle.net/5sWue/2/" rel="nofollow noreferrer">jsfiddle</a>. Although it's not working in the fiddle. There might be some unused code. I'm busy removing it as I go along.</p> <p>I've got these files attached:</p> <pre><code>&lt;link href='assets/css/kendo.custom.css' rel='stylesheet' type='text/css' /&gt; &lt;link href='assets/css/kendo.common.min.css' rel='stylesheet'/&gt; &lt;link href='assets/css/kendo.default.min.css' rel='stylesheet' type='text/css' /&gt; &lt;script src='assets/js/jquery.min.js'&gt;&lt;/script&gt; &lt;script src='assets/js/kendo.all.min.js'&gt;&lt;/script&gt; </code></pre> <p>and how can I fix this issue that data will be displayed in the grid?</p> <p>Any help will be appreciated, thanks...</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.
    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