jQuery UI Widgets Forums Grid Don't get data on page first load

This topic contains 4 replies, has 2 voices, and was last updated by  romulocpd 9 years, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Don't get data on page first load #69926

    romulocpd
    Participant

    Hello.

    The JQXGrid is working very well, but I have a problem.

    Just the page load the DataSource is loaded and the grid is loaded too. I need the grid be loaded just when I click on the button and raise a POST to get data (via ajax)

    
    var sourceGrid = {
                dataType: 'json',
                id: 'Id',
                url: '@Url.Action("ObterAbastecimentosJSON", "Abastecimento", new { area = "Manutencao" })',
                dataFields: [
                { name: 'Id', type: 'number' },
                { name: 'NumeroFormulario', type: 'number' },
                { name: 'TipoAbastecimento', type: 'string' },
                { name: 'TipoEstoque', type: 'string' },
                { name: 'LocalEstoque', type: 'string' },
                { name: 'QtdEquipamentos', type: 'number' },
                { name: 'QtdLitros', type: 'number' },
                { name: 'ValorAbastecimento', type: 'number' },
                { name: 'Posto', type: 'string' },
                { name: 'DataAbastecimento', type: 'date' },
                { name: 'Empresa', type: 'string' },
                { name: 'BaseOperacional', type: 'string' },
                { name: 'Equipamento', type: 'string' },
                { name: 'Colaborador', type: 'string' },
                { name: 'Usuario', type: 'string' }
                ]
            };
    
            var dataAdapter = new $.jqx.dataAdapter(sourceGrid);
    

    The sourceGrid is faired just the page is load at first time.

    Thank you

    Don't get data on page first load #69934

    Dimitar
    Participant

    Hello romulocpd,

    If you wish the grid to appear only after the button click, initialize it in the Ajax call’s success callback, not in $(document).ready(). If you wish the grid to be empty initially (showing “No data to display”) and be populated when you click the button, set its source property in the Ajax call’s success callback.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Don't get data on page first load #69960

    romulocpd
    Participant

    Hello.

    I’ve solved the problem.

    
    $("#Grid").jqxGrid('clear');
    $("#Grid").jqxGrid({ source: dataAdapter });
    

    Is it the better way?

    Thank you.

    Don't get data on page first load #69961

    Dimitar
    Participant

    Hello romulocpd,

    This is a correct approach but there is no need to clear the grid, just reset its source.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Don't get data on page first load #69964

    romulocpd
    Participant

    Hello Dimitar.

    If I don’t clear the grid an error occours.

    `jqxgrid.filter.js:7 Uncaught TypeError: Cannot read property ‘0’ of null’

    But works!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.