When you define a grid, you pass in XML configuration for the grid. We have seen many examples of this so far, but lets look at a simple example here:
$(document).ready(function () {
var grid = new flexiciousNmsp.FlexDataGrid(document.getElementById("gridContainer"),
{
configuration: '<grid id="grid" enablePrint="true" enablePreferencePersistence="true" enableExport="true" forcePagerRow="true" pageSize="50" enableFilters="true" enableFooters="true" enablePaging="true">' +
' <level>' +
' <columns>' +
' <column type="checkbox"/>'+
' <column dataField="id" headerText="ID" filterControl="DynamicFilterControl" footerLabel="Sum: " footerOperation="sum" footerOperationPrecision="2"/>' +
' <column dataField="type" headerText="Type" filterControl="TextInput" filterOperation="Contains" />' +
' </columns>' +
' </level>' +
' ' +
' </grid>',
dataProvider: [
{ "id": "5001", "type": "None", "active": true },
{ "id": "5002", "type": "Glazed", "active": true },
{ "id": "5005", "type": "Sugar", "active": true },
{ "id": "5007", "type": "Powdered Sugar", "active": false },
{ "id": "5006", "type": "Chocolate with Sprinkles", "active": true },
{ "id": "5003", "type": "Chocolate", "active": false },
{ "id": "5004", "type": "Maple", "active": true }
]
});
});
As you see above, we basically pass in an XML string to the constructor of the FlexDataGrid class. One very frequent question comes up is, "What are the various attributes you can specify in XML"?
The answer is simple. All of them. Each and every property mentioned in the documentation can be specified via XML. This includes both properties explicitly exposed as public attributes (e.g. enablePrint, enableExport etc) , and some that are exposed via setters (e.g. setPagerRowHeight, setPagerVisible) . The XML parser is smart enough to figure out if there is a setter with the naming convention setXXXX and use it instead of a direct value set on the property. (This is in red because it often causes confusion among our customers). So pageSize="50" automatically translates to setPageSize(50), even if there is no property called pageSize on FlexDataGrid, but because there is a method named setPageSize. It is also smart enough to figure out that a value is a number passed in as a string, so it will do that conversion as well.
In addition to the above, the XML builder does a lot of preprocessing of the string values passed into it. These steps are described below.