Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #100640

    Hey there,
    Would someone be able to give me a working example that uses an ajax call to an aspx.cs page to get data on demand?
    I have not been able to figure out how to implement a data adapter that uses ajax or how to do it without the use of the data adapter. Any help would be greatly appreciated.


    Hi ctstrist,
    Currently, Smart.DataAdapter cannot get data from a file, but we are working on this functionality and hope that it will soon be available.
    In the meantime, you can use fetch (or XMLHttpRequest, or jQuery.ajax()) to request the file’s data and then pass it as an array to the Grid, as is done in the code snippet below:

    fetch('../../../scripts/beverages.json', { method: 'GET' })
        .then(function (response) {
            if (response.ok) {
                return response.json();
        .then(function (data) {
            Smart('#grid', class {
                get properties() {
                    return {
                        appearance: {
                            alternationCount: 2,
                            showRowHeader: true,
                            showRowHeaderSelectIcon: true,
                            showRowHeaderFocusIcon: true
                        paging: {
                            enabled: true
                        pager: {
                            visible: true
                        sorting: {
                            enabled: true
                        editing: {
                            enabled: true
                        selection: {
                            enabled: true,
                            allowCellSelection: true,
                            allowRowHeaderSelection: true,
                            allowColumnHeaderSelection: true,
                            mode: 'extended'
                        behavior: { columnResizeMode: 'growAndShrink' },
                        dataSource: new Smart.DataAdapter(
                                dataSource: data,
                                        'name: string',
                                        'type: string',
                                        'calories: int',
                                        'totalfat: string',
                                        'protein: string'
                        columns: [
                            { label: 'Name', dataField: 'name' },
                            { label: 'Beverage Type', dataField: 'type' },
                            { label: 'Calories', dataField: 'calories' },
                            { label: 'Total Fat', dataField: 'totalfat' },
                            { label: 'Protein', dataField: 'protein' }
        .catch(function (error) {

    Best regards,
    Smart HTML Elements Team


    does the data adapter work with sql calls?


    we expected the call to look like this

    const dataAdapter = new Smart.DataAdapter({
    dataSource: {
    method: “GET”,
    url: “Productivity/?handler=Dashboard”,
    async: true
    dataSourceType: “json”,
    dataFields: [
    “Category: string”,
    “DateValue: date”,
    “CurrentPeriod: bool”


    but it is not calling the code behind in my project


    Hi Bryan,

    It works with SQL calls, example: If you have more complex scenario, you can use the native fetch and bind the grid to the fetch’s result.

    Best regards,
    Peter Stoev

    Smart UI Team

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.