Execute code when the report is loaded.

Originally Posted 15 August 2017, 5:43 am EST

  • Originally Posted 15 August 2017, 5:43 am EST

    Hi,

    I'm wondering if there is a way I can know that the report is ready to accept my flex.columnLayout string once the report is loaded.
    I now need to do setTimeout(function(){}, 50); to achieve this. Is there any listener like the one you've got for angular "initialize" directive ?

    I'm not using angular in my case.

    Regards,
    Aleks.
  • Reply

    Hi Alex,
    You can use initialize method for the same. Please refer to the code snippet:

    let grid= new wjGrid.FlexGrid("#grid");
    grid.initialize({
    itemsSource:cvData,
    columnLayout: customLayout
    });



    Thanks,
    Manish Kumar Gupta
  • Reply

    Hi Aleks,
    If you would not like to use loadedRows event, you can use initialize method for the same for setting columnLayout if you would like to do it in TS file. You can also use initialized event which can be defined within FlexGrid directive.

    Could you please elaborate your requirement so that we can assist you precisely?

    Thanks,
    Manish Kumar Gupta
  • Reply

    Hi,

    Thanks for the reply.
    Yes I'm referring to the FlexGrid component.
    I did see the loadedRows event but I don't want to execute code when I load new rows or I do whatever type of rows action in the component while its rendered on the page. I only need to execute code once when the component is loaded. Normally the component should have something like $(document).ready method that jQuery library have.

    Technically saying it should have onLoad event followed by a callback function to execute code when the component is rendered and fully loaded on the page.

    Another alternative way I came up with is when I finish the ajax call in .done() i execute the code once the component gets rendered but this is still a workaround. I might need to handle different type of code in future so ajax promises might not be the solution.

    Regards,
    Aleks.
  • Reply

    Hi Aleks,
    Could you please confirm if you are referring to ReportViewer or FlexGrid control. If you are referring to FlexGrid, you can use loadedRows event.

    Thanks,
    Manish Kumar Gupta
  • Reply

    And what happens if I want to execute alert("something"); when the grid is loaded completely for the first time, how do i do that?
  • Reply

    I told you i'm not using angular.
  • Reply

    Hello,
    Please refer to the fiddle that implements the same.

    Thanks,
    Manish Kumar Gupta
  • Reply

    I tried that against new wijmo.grid.FlexGrid and it didn't work.
  • Reply

    Hi,

    Sorry, this doesn't do the job for us.
    We have implemented a logic where in this case updatedLayout callback method is being executed 3 times. So the first time when it gets executed the report is still not rendered on the page and for the second and the third time the isLoad flag is already being set which doesn't fix the issue we've got here.
    On the other hand we don't want this code to be executed every time we update the layout when user interacts with the grid, we do tend to optimize the code as much as we can.

    Any other solution will be highly appreciated. As said I only need to execute code only when the grid is fully rendered on the page for the first time and never again.

    Regards,
    Aleks.
  • Reply

    Hi Aleks,
    We are sorry for the inconvenience caused.
    You can get cell HTML using upatedLayout or updatingLayout event once data is loaded in FlexGrid. You can also create a tooltip instance before FlexGrid initialization. You need to handle mousemove and mouseout event to show/hide tooltip.
    For your reference, please refer to the updated fiddle that implements the same.

    Hope it helps!

    Thanks,
    Manish Kumar Gupta
  • Reply

    This doesn't do the job for me again :( and as far as i can see not even in your case. See the screenshot i'm sending with this link.
    http://prntscr.com/ggv7se
    You can clearly see that "ItemsSource Changed null" which means you don't have access to the elements .. they still haven't finished rendering on the page.
    And locally when i try to remove the setTimeout i also get this error : http://prntscr.com/ggvaee when the console.log tries to execute.
    For example I have another requirement now to apply custom tooltip we are developing here so when the report loads completely I need to create a tooltip instance for each column header and this ticket we are trying to solve for this long time is blocking me of doing what i need to do.

    Thanks,
    Aleks.
  • Reply

    Hi Aleks,
    Not sure but it seems data loaded with some delay in the FlexGrid. Hence, you are unable to accomplish your task. In such, case you need to use itemsSourceChanged event to set variable.

    For your reference, please refer to the attached fiddle for the same.


    Thanks,
    Manish Kumar Gupta
  • Reply

    Hi,
    If you would like to show alert just after row loaded but not rendered, you can use loadedRows event. If you would like to show alert after complete FlexGrid rendering, you can use updatedLayout event with some constraint.
    For your reference, please refer to the following code snippet:
    let isLoad=true;
    grid.updatedLayout.addHandler(this.updatedLayout);
    updatedLayout(s,e){
    if(isLoad){
    alert("Something");
    isLoad=false;
    }
    }



    Thanks,
    Manish Kumar Gupta
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels