JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › Using DataGrid with AJAX/JSON data
Tagged: Ajax, grid, Grid data, JSON, smart grid
- This topic has 1 reply, 2 voices, and was last updated 4 years ago by admin.
-
AuthorPosts
-
November 9, 2020 at 3:05 pm #101135adminKeymaster
I have been a user of JQWidgets for a while, but just getting started with Smart. I have a page with a grid… data has been preloaded via AJAX into a JSON object. With JQWidgets, I would use a dataAdapter with localdata set to the name of my JSON object. ‘localdata’ does not appear to be a valid property with Smart’s dataAdapter. I have finally been able to get data to display by using dataSourcetype of ‘array’, and setting dataSource to my json object (called comp_data). I am obviously doing something wrong, because whenever I click on a column heading, while the column sorts, I also get a javaScript error. ‘Cannot read property ‘disabled’ of undefined. Error occurs on smart.grid.gs line 8.
I am loading ‘..source/modules/smart.grid.js’ and ‘..smart.default.css’. Here is my code.
var dataAdapter = new Smart.DataAdapter({
dataSourceType: ‘array’,
dataFields:
[
‘ACCOUNT_NAME:string’,
‘CITY:string’,
‘COUNTRY_CODE:string’,
‘DOMESTIC_ULTIMATE:string’,
‘DOMESTIC_ULTIMATE_ID:string’,
‘EMAIL_ADDRESS:string’,
‘GLOBAL_ULTIMATE:string’,
‘GLOBAL_ULTIMATE_ID:string’,
‘INDUSTRY:string’,
‘POSTAL_CODE:string’,
‘REGISTRY_ID:string’,
‘STATE:string’,
‘SUB_INDUSTRY:string’,
‘TERRITORY_ID:string’
],
dataSource: comp_data.rows
});
const grid = new Smart.Grid(‘#grid’, {
appearance: {
alternationCount: 2,
showRowHeader: true,
showRowHeaderSelectIcon: true,
showRowHeaderFocusIcon: true
},
paging: {
enabled: true
},
pager: {
visible: true
},
sorting: {
enabled: true
},
editing: {
enabled: false
},
filtering: {
enabled: true
},
selection: {
enabled: true,
allowCellSelection: true,
allowRowHeaderSelection: true,
allowColumnHeaderSelection: true,
mode: ‘extended’
},
behavior: { columnResizeMode: ‘growAndShrink’ },
dataSource: dataAdapter,
columns: [
{label: ‘Account Name’, dataField: ‘ACCOUNT_NAME’},
{ label: ‘Industry’, dataField: ‘INDUSTRY’ },
]
});
Second Issue: I am getting a toast style message in the bottom corner of my webpage showing htmlelements.com. I am pretty certain that this is telling me that I am using a demo version of Smart. To get my code, I went to jqwidgets, went through the client login, and downloaded from there. The page I downloaded from showed unzip codes, etc… although it never asked for the codes when I unzipped.</div>November 10, 2020 at 8:18 am #101137adminKeymasterHello george@woh.rr.com,
1. Your code seems correct. We created a demo with some sample data in JSON format and your Grid settings and it works as expected: https://codepen.io/dimitar_jqwidgets/pen/ExyOYQX?editable=true%3Dhttps%3A%2F%2Fwww.htmlelements.com%2F.
2. Please contact support@jqwidgets.com for more information on how to remove the licensing message.
Best regards,
Dimitar
Smart HTML Elements Team
https://www.htmlelements.com -
AuthorPosts
- You must be logged in to reply to this topic.