Click here to Skip to main content
15,887,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a custom control that implements the client side grid SlickGrid[^].

I want to populate the data on page load. I have several custom javascript functions that can do this so I just need to get the json object.

Do I have to 'fetch' this data on page load or can I write it in the page metadata somewhere? I toyed with the idea of just writing it line for line in dynamic js but it just looks bad :S

Thanks
Andy

PS: My boss said I should just use telerik kendo, but I fail to see the advantage.

UPDATE: There does not appear to be a way of preloading the datasource other than writing it onto the page. I'll have to stick with a web service.
Thanks to RyanDev.

UPDATE (again):
RyanDev came up with a good idea ^_^
Posted
Updated 23-Jul-15 5:26am
v3
Comments
ZurdoDev 23-Jul-15 8:16am    
I'm not sure what your question really is. Sure, you can get data in Page_Load.
Andy Lanng 23-Jul-15 8:53am    
the grid is client-side. all in javascript.

I would rather build the json data object server-side and hand it to the client (somehow) to build the grid client-side that have a javascript function that fetches it on document.ready
ZurdoDev 23-Jul-15 8:55am    
WebService then? Call it from document.ready.
Andy Lanng 23-Jul-15 10:20am    
That's what I'm going with. I just hoped there was a way I could pre-load it before the document was ready.

If you can't think of an alternative, RyanDev, then I doubt there is one ^_^

Thanks
ZurdoDev 23-Jul-15 10:25am    
Before document ready? You could in page load do the processing and put it into a hidden field that document.ready then uses.

1 solution

As mentioned in the comments, you could load the data into a hidden field on the page in the Page_Load event. Then in the document.ready you can start using it right away.

However, this may give the impression that your page loads slowly. Many people do the opposite to have a more reactive page. They let the page load quickly and then do the processing in document.ready.

Clearly it's your choice of which way works best for you.
 
Share this answer
 
Comments
Andy Lanng 23-Jul-15 11:27am    
Yeah, I think you talked me out of it, but it answered my question :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900