Working with Datatable and Blazor Server side
Working with Datatable and Blazor Server side
walter.iermano@live.com
Posts: 5Questions: 3Answers: 0
I love working with datatable but I can't use it with server side Blazor, is there anyone who has a really working example?
i followed a few posts here but i couldn't get it to work
Answers
This thread should help, it's asking the same thing.
Cheers,
Colin
Thanks but in server side not works
What isn't working?
Are you getting alert messages or errors in the browser's console?
Kevin
Thanks now all is ok
I faced the same issue and couldn't get the code on https://datatables.net/forums/discussion/56389/datatables-with-blazor to work 100% for me.
See https://stackoverflow.com/questions/62176800/using-datatables-net-with-server-side-blazor-application/62182706 for how I got it working.
What approach did you take?
For a complete tutorial and solution, check out his post:
https://gmtech.co.za/how-to-add-js-data-tables-to-your-blazor-project/
Good information, thanks for sharing,
Colin
So I took all the ideas I found here fined it down to what I called an improvement.
Just sharing in case anyone thinks it an improvement like I did.
First create a DataTable.razor component like the following:
Then create a JavaScript file, place a reference to it after the body tag in your _Host.cshtml file, then add the following function within
And that's it, works perfectly. Here is an example of me using mine:
Thanks for posting!
Colin
Hey I have made even more improvement and thought I should share
These changes allow for a more natural feel of using a component that is suppose to generate a table tag and also allow for the ability to add CSS attributes. Now the component is more reusable.
Also, if you want to ensure that you don't accidentally supply an ID attribute to the component and override its dependent "id" value; place the "id" attribute after the attribute splatting implementation like this:
This will protect the "id" attribute from being overridden... cheers!
Hi, you need to put within "div" to solve the issues of not clearing head and footer of DataTable while clicking on other page in Blazor.
Or making DataTable component within div as the following code then you do not worry about fogetting "div", it works for me. Thanks very much.
Nice, thanks for posting,
Coln
how to use server-side datatable in blazor server?
server-side datatable using ajax to get data.
I used to doing this in webform webmethod.
but how to do in blazor?