DataTables Not Fully Working Correctly with ASP.NET GridView Paging (only searches current page)

DataTables Not Fully Working Correctly with ASP.NET GridView Paging (only searches current page)

celbestercelbester Posts: 5Questions: 0Answers: 0

I have an ASP.NET GridView with the following setup:
1. Sorting is implemented using ASP.NET GridView's Sorting (OnSorting="gridList_Sorting")
2. Paging is implemented using ASP.NET GridView's Paging (OnPageIndexChanging="gridList_PageIndexChanging")
3. Searching/Filtering is implemented using JQuery DataTables

Background: The setup is that way because the GridView needs to be editable. I tried implementing sorting, paging, and searching/filtering exclusively using DataTables but I get the issue of the row-being-edited jumping unpredictably within the GridView (the row's position changes when it's clicked to be edited), and I wasn't able to solve it.

Going back, the issue is DataTables is only able to filter if the record occurs in the current GridView page. Example: In the edited image below, searching for "Fiona Green" will not display the filtered results. However, searching for "Hope" will display the filtered results.

Due to a tight time constraint, I need to maintain the setup (sorting and paging is done by ASP.NET GridView while searching/filtering is done by JQuery DataTables). I hope someone can help advise on troubleshooting and solving this issue. Advanced thanks!!!

Replies

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @celbester ,

    If the only data DataTables has is in the current view, then that's all it can search upon. You could try serverSide perhaps. The protocol is discussed here.

    Cheers,

    Colin

  • celbestercelbester Posts: 5Questions: 0Answers: 0

    Thanks for replying, Colin! Yes, you're right, my JQuery DataTables is currently configured to operate on client-side only. Sigh, that means is that the ASP.NET GridView is only returning results for the current page versus ASP.NET GridView returning all results then paging it at client-side : ( By any chance, have you tried applying ServerSideProcessing in JQuery DataTables but retain ASP.NET GridView paging? I wonder if it'll conflict.

  • allanallan Posts: 61,722Questions: 1Answers: 10,108 Site admin

    It will almost certainly conflict I'm afraid. They are two entirely different paging systems. You might be able to use the ASP grid view paging and layer a DataTable on top of it, but DataTables won't actually be gaining you anything that. You'd be better of using use the ASP grid view at that point.

    I'd suggest using either DataTables or the grid view component. Not trying to mix them

    Allan

  • rafiullahrafiullah Posts: 1Questions: 0Answers: 0

    It is not working with asp.net Gridview. I already add the Css & js files of Datatable, and called this:

    $(document).ready(function () { $('.table').DataTable(); });
  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    @rafiullah Please see Allan's last reply, he explains that.

  • apcashishapcashish Posts: 1Questions: 0Answers: 0

    I have explained everything related to datatable and grid view with all features and css and js codes in ASP.Net C#
    <a href="https://blog.oxirock.com" >Click Here</a>

This discussion has been closed.