Kendo Grid displaying local data | Sololearn: Learn to code for FREE!
0

Kendo Grid displaying local data

My Kendo Grid is getting the correct data, however, I am forced to click on the refresh button on the grid in order to display the data instead of it automatically showing on load. How can I get the data to display automatically without having to press the refresh button? // calcs is run in a loop to get all of the data into an array calcs = { RollDiameter: parseFloat(Math.round(view[1].RollDiameter * 100) / 100).toFixed(2), Footage: view[1].Footage, Impressions: view[1].Impressions, SquareInches: parseFloat(Math.round(view[1].decFutureUse01 * 100) / 100).toFixed(2), RollWeight: parseFloat(Math.round(view[1].RollWeight * 100) / 100).toFixed(2) }; calculations.push(calcs); $("#grid").kendoGrid({ toolbar: ["pdf"], pdf: { allPages: true, avoidLinks: true, paperSize: "A4", margin: { top: "2.6cm", left: "1cm", right: "1cm", bottom: "1.8cm" }, landscape: false, repeatHeaders: true, template: $("#page-template").html(), scale: 0.8 }, dataSource: { data: calculations, pageSize: 20 }, // height: auto, sortable: false, groupable: false, pageable: { refresh: true, pageSizes: true, buttonCount: 5 }, columns: [{ field: "RollDiameter", title: "Roll Diameter

31st Jan 2019, 5:23 PM
jake sarosiek
jake sarosiek - avatar
1 Answer
0
You provide only partial code, so it's hard to be precise ^^ However, a possible solution track is to trigger the click event (call the .click() merhod) of your "refresh" button (the html element), when data is ready (initialization is done) and the page was loaded... Suppose the button html code was somtmething like: <button id="refresh_btn">refresh</button> You need some js as (for example): init_data(); // where data are set init_html(); // where the click handler is defined if not inlined in button onclick attribute window.addEventListener('load',() => document.getElementById('refresh_btn').click(); ); Obviously, if your init code is already in an onload event handler function, or your script is inside the <body> part of the html source, after the target button declaration, you must avoid the "addEventListener" call but keep the code inside (call to trigger the onclick event).
26th Mar 2020, 4:27 PM
visph
visph - avatar