Results 1 to 7 of 7

Thread: Help/Advice for binding datatable with paging to page.

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2013
    Posts
    61

    Post Help/Advice for binding datatable with paging to page.

    Hi, looking for any help i can get... as I'm sure this type of thing will be easy to those who know how.

    I've come across a problem in my work where I have data in my datatable after it has been retrieved and then it is binded to a repeater in a table on aspx page. There are about 1000 records.

    It's takes a really long time client side to load the page and I wanted to try to implement something different that I have seen before and try that. The only problem is I am not sure how to implement it.

    An example of it is here.. https://datatables.net/examples/basi...agination.html and it looks like a small bit of javascript does the job

    Code:
    $(document).ready(function() {
        $('#example').DataTable( {
            "pagingType": "full_numbers"
        } );
    } );
    What I am not sure about is where to put the javascript on my aspx page, do I completely remove my previous repeated from aspx page and do I need anything different.... and if I need to do anything different in vb.code. From memory when I saw this used in the past the little bit of javascript did all the work with column headers etc.

    I suppose what I'm looking for is the very basic of examples which i can understand and put into my solution. I am not very good with Javascript. Bearing in mind I don't even know if "#example" is supposed to be the name of my datatable.

    For example I have... if we pretend I have my datatable called PagingDT with 1000 records... can someone explain or possibly provide an example of the basic bit of code I need to get it to bind and display on a page with the paging and maybe what order things are done and where. Let's pretend I'm an idiot.. lol.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Help/Advice for binding datatable with paging to page.

    That's not just JavaScript but specifically jQuery, so you need to make sure that you have added the appropriate jQuery files and references to your project.

    As for the code, I haven't used Web Forms for a long, long time but I would assume that it would be no different to MVC and you simply put that code at the top of a <script> element. It's basically registering a handler for the 'ready' event of the 'document' object and providing a function to execute when that event fires. It's much like handling the Load event of a form in Windows Forms but in the HTML executed by the browser.

    EDIT: Actually, it's more like the Shown event of a form that the Load event, because it happens after the content is displayed rather than before.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Help/Advice for binding datatable with paging to page.

    Quote Originally Posted by VB.NETGAL View Post
    I am not very good with Javascript. Bearing in mind I don't even know if "#example" is supposed to be the name of my datatable.
    That is a jQuery selector. That line basically says get the element(s) with an id of "example" and then execute the DataTable function on them. DataTable would be a function defined in a jQuery plug-in somewhere that can perform an action on the type of element(s) retrieved by the selector '$("#example")'. It may be expecting a <div> with a specific internal structure of it may be expecting an <input> or something else. The plug-in documentation should explain what it can act on.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Help/Advice for binding datatable with paging to page.

    By the way, this question really has nothing specifically to do with VB.NET so I've asked the mods to move it to ASP.NET.

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Help/Advice for binding datatable with paging to page.

    Thread moved to the 'ASP.Net' forum, which is where questions about .Net web pages etc belong

  6. #6
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Help/Advice for binding datatable with paging to page.

    It's takes a really long time client side to load the page and I wanted to try to implement something different that I have seen before and try that.
    Have you checked your logic in the code-behind if retrieving of those records are slow or fast?

    - kgc
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  7. #7
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Help/Advice for binding datatable with paging to page.

    Like KG says, you are limited to the time the record load.
    However you can load you data asynchronous and have the page showing a loading gif somewhere while the page is responsive and does not wait for all the data to load before showing up.
    So the page will load up and in the background all data will be loading.
    So, as I haven't done this for a long time, leeetsss, look for an example...Anddd, here. Take a look at this:
    http://iainhoult.blogspot.gr/2010/07...usly-load.html
    Haven't tested but is the basic idea.

    A second Idea would be to use a paging Jquery gridview. I believe @szlamany
    has done so with a slick grid. I was to use one but got a job that took all the time from freelancing.
    Last edited by sapator; Mar 27th, 2018 at 09:57 AM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width