Reputation: 47
I have downloaded Dgrid and, after renaming a folder in dgrid, i move it in Dojo folder.
In the HTML I include it like so:
<!--application UI goes here-->
<script type="text/javascript" src="dgrid/Grid.js"></script><!--prova importazione Dgrid-->
<script src="js/initOptions.js"></script>
<script src="js/MobileACG.js"></script>
Next I set it in build_dojo.xml:
<include name="dgrid/Grid.js" />
The error is in the require
row below:
function creaGridTableArticoli(){
dgrid
require(["dgrid/Grid"], function(Grid){
var columns = {
first: {
label: "First Name"
},
last: {
label: "Last Name"
}
};
var grid = new Grid({ /* options here */ }, "grid");
WL.Logger.debug("ok");
});
}
Upvotes: 2
Views: 335
Reputation: 44516
Note: In regard to Dojo, IBM Worklight only supports the IBM Dojo Toolkit for both runtime and tooling.
The IBM equivalent of dgrid is gridx.
That said, follow these steps to make dgrid work in your Worklight project.
In Worklight 5.0.6
Open build-dojo.xml and add the following includes:
<include name="dojo/_base/declare.js"/>
<include name="dojo/domReady.js"/>
<include name="dgrid/**"/>
<include name="put-selector/*"/>
<include name="xstyle/**"/>
Open the HTML file and add a new script tag inside the HEAD element. Populate it with this code:
require(["dgrid/Grid", "dojo/domReady!"], function(Grid) { var data = [ { first: "Bob", last: "Barker", age: 89 }, { first: "Vanna", last: "White", age: 55 }, { first: "Pat", last: "Sajak", age: 65 } ]; var grid = new Grid({ columns: { first: "First Name", last: "Last Name", age: "Age" } }, "grid"); grid.renderArray(data); });
Add the following inside the BODY element:
<div id="grid"></div>
Preview in Worklight Console
You can also preview in the Design perspective in Eclipse, although I've noticed some rendering issue there in the table (not seen in the MBS (below); I guess it's fixable in CSS...).
Full size image: https://i.sstatic.net/B36qU.png
Upvotes: 2