Giter Site home page Giter Site logo

DataTables issue about starlette-admin HOT 7 CLOSED

jowilf avatar jowilf commented on May 21, 2024
DataTables issue

from starlette-admin.

Comments (7)

jowilf avatar jowilf commented on May 21, 2024

Hello @mariofix,
Glad you find it impressive,

When you customize fields you need to add at least the primary key field. Datables need this primary key to differentiate each row.

Thank you

from starlette-admin.

mariofix avatar mariofix commented on May 21, 2024

Excellent, that fixed the warning. Thank you!

Although I believe the PK should be included no matter what, or at least a way to disable the warning.

Is there a way to disable the ajax call for the table?

from starlette-admin.

jowilf avatar jowilf commented on May 21, 2024

Hello @mariofix ,
May I ask why you need to disable the ajax call? because the list is rendered via ajax call.
You don't want to use the list page?
If you don't want the primary key in your list page, you can exclude it

from starlette-admin.

mariofix avatar mariofix commented on May 21, 2024

Hi! Thanks for your quick reply and I'm sorry, it appears I'm not making myself very clear.

I no not wish no exclude the PK, I only believe that the PK should not be optional for that type of view.
If someone make the same mistake I did, they would take quite a few to get to the answer, because the behaviour is pretty weird:
If I get the warning, it goes away if I include the PK in the fields parameter, fair enough
If the PK is not present, I get the warning but I still get to view and edit the record via the action icons, so DataTables shouldn't complaint, because the PK is present.

Regarding DataTables, for stuff like this I've never had a pretty good experience with the way DT makes the ajax calls and prepares the data, so I try to avoid DT as much as possible.
Besides, i'm still not there (I'm migrating from sqladmin) but I will need to modify the queryset at some point, I can't imagine that mess with the DataTables ajax calls.

I'm more than happy to code that, but not if you are not considering it or you already have something to that effect.
Best regards

from starlette-admin.

jowilf avatar jowilf commented on May 21, 2024

Hello,
I think it's very clear now,
To resume:

  • The warning can be solved by returning the primary key to Datatables even if it not specify in fields ( i think this is a bug, should be fixed)
  • Add support for list_query and count_query to ease the query customization for SQLAlchemy (and maybe find similar solution for others backend)

wdyt?

And to add a little clarification about custom queries, you will never deal with the ajax request, you just need to override the crud methods inside your ModelView. You can override for example the find_all method to add your own logic

from starlette-admin.

mariofix avatar mariofix commented on May 21, 2024

Superb!
How can I help?

from starlette-admin.

jowilf avatar jowilf commented on May 21, 2024

Superb! How can I help?

Hello @mariofix,
you have already done well by reporting this issue, thank you.

I will close this issue now and open two others issues #36 & #38

from starlette-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.