jQuery UI Widgets Forums Grid Grid's 'initialized' event not fired when source is bound to local data

This topic contains 2 replies, has 2 voices, and was last updated by  sushengloong 12 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • sushengloong
    Member

    Hi,

    I bind a grid’s initialized event to a function which does something. When I bind the same grid to a local JS data, the grid’s ‘initialized’ event doesn’t seem to fire as the function is not executed when the grid has been loaded. However, when I bind the same grid to a remote URL which returns the same JSON data, everything works correctly. May I know whether this is the expected behavior or bug? Thank you!

    Thanks,
    Sheng Loong


    Peter Stoev
    Keymaster

    When do you bind to the ‘initialized’ event – before or after calling the jqxGrid constructor? When you bind to events such as ‘initialized’ you should expect the event to be raised when the Grid is initialized and the data is loaded. When you load the jqxGrid from local data the event is raised when the jqxGrid constructor function is called i.e you should bind to the ‘initialized’ event before calling the constructor. The same is valid for the ‘bindingcomplete’ event. The remote data is loaded asynchronous and that’s why the event is raised when you bind to it after calling the jqxGrid constructor.

    Example:

      $("#jqxgrid").bind('initialized', function () {
    alert('grid');
    });
    $("#jqxgrid").jqxGrid(
    {
    width: 670,
    source: source,
    theme: theme,
    filterable: true,
    sortable: true,
    autoheight: true,
    columnsresize: true,
    groupable: true,
    pageable: true,
    autoshowfiltericon: true,
    columns: [
    { text: 'First Name', datafield: 'firstname', width: 300 },
    { text: 'Last Name', datafield: 'lastname', width: 300 },
    { text: 'Product', datafield: 'productname', width: 280 },
    { text: 'Order Date', datafield: 'date', width: 100, cellsformat: 'd' },
    { text: 'Quantity', datafield: 'quantity', width: 280, cellsalign: 'right' },
    { text: 'Unit Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2' }
    ]
    });

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    sushengloong
    Member

    Hi Peter,

    I see. Thank you for your answer.

    Thanks
    Sheng Loong

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

You must be logged in to reply to this topic.