jQWidgets Forums
jQuery UI Widgets › Forums › Grid › columntype: 'number' sets field to AutoIncrement
Tagged: columntype auto increment number
This topic contains 2 replies, has 2 voices, and was last updated by Makla 12 years, 2 months ago.
-
Author
-
I didn’t expect something like that when reading api documentation:
columntype – sets the column’s type.
Possible values:
‘number’ – readonly column with numbers.When changing columntype to number the values become auto increment.
I add columntype of quantity to number:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Demo</title> <script src="Framework/Scripts/jquery-1.9.1.min.js"></script> <script src="Framework/Scripts/knockout-2.2.1.js"></script> <script src="Framework/Scripts/jqwidgets/jqx-all.js"></script> <link rel="stylesheet" href="Framework/Styles/jqx.base.css" type="text/css" /> <link rel="stylesheet" href="Framework/Styles/jqx.ui-sunny.css" type="text/css" /> <script type="text/javascript"> $(document).ready(function () { // prepare the data var data = new Array(); var firstNames = [ "Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene" ]; var lastNames = [ "Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier" ]; var productNames = [ "Black Tea", "Green Tea", "Caffe Espresso", "Doubleshot Espresso", "Caffe Latte", "White Chocolate Mocha", "Cramel Latte", "Caffe Americano", "Cappuccino", "Espresso Truffle", "Espresso con Panna", "Peppermint Mocha Twist" ]; var priceValues = [ "2.25", "1.5", "3.0", "3.3", "4.5", "3.6", "3.8", "2.5", "5.0", "1.75", "3.25", "4.0" ]; for (var i = 0; i < 100; i++) { var row = {}; var productindex = Math.floor(Math.random() * productNames.length); var price = parseFloat(priceValues[productindex]); var quantity = 1 + Math.round(Math.random() * 10); row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)]; row["lastname"] = lastNames[Math.floor(Math.random() * lastNames.length)]; row["productname"] = productNames[productindex]; row["price"] = price; row["quantity"] = quantity; row["total"] = price * quantity; data[i] = row; } var source = { localdata: data, datatype: "array" }; var dataAdapter = new $.jqx.dataAdapter(source, { loadComplete: function (data) { }, loadError: function (xhr, status, error) { } }); $("#jqxgrid").jqxGrid( { source: dataAdapter, columns: [ { text: 'First Name', datafield: 'firstname', width: 100 }, { text: 'Last Name', datafield: 'lastname', width: 100 }, { text: 'Product', datafield: 'productname', width: 180 }, { text: 'Quantity', datafield: 'quantity', width: 80, cellsalign: 'right', columntype: 'number' }, { text: 'Unit Price', datafield: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2' }, { text: 'Total', datafield: 'total', width: 100, cellsalign: 'right', cellsformat: 'c2' } ] }); });</script></head><body class='default'><div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;"> <div id="jqxgrid"></div></div></body></html>
Hi Makla,
The documentation is correct. The “number” column type shows only numbers in the column starting from 1.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comUnderstand. Maybe it would be a good think to add in documentation ” in the column starting from 1.”
Thank you. -
AuthorPosts
You must be logged in to reply to this topic.