DataTables / Vue

Vue plugin for DataTables
MIT License
64 stars 12 forks source link

Confusion over date type with columns? #40

Open ajmcgrail opened 2 weeks ago

ajmcgrail commented 2 weeks ago

Hi there. I've got a stackblitz here that I'm a little confused about. In one table, I have the option serverSide true on one and on the other set to false. On the table where serverSide is set to true, when trying to filter on the updated_at column, it does not show the normal date filtering options (conditions), while it does when serverSide is set to false.

Any chance I could get clarification on why this happens or how to fix this? The case I care about is where serverSide is true, and I think this bug started happening within the last few months, because I'm almost certain this used to work where it would correctly detect that it was a date.

Thanks for your time.

P.S. while debugging I found that you edit the given prop objects in the DataTable component. I don't recommend doing that, and recommend instead using computed values in a more functional manner, because changes to an object prop interact oddly with the parent. I thought that using a computed value might be the problem, but it doesn't seem to be for this at least, or when using a computed value for options or ajax props.

AllanJard commented 2 weeks ago

Recent DataTables releases do not attempt to automatically figure out the data type for a column when using server-side processing. Since it only has a limited subset of the data available, this approach was error prone and could result in the data type changing between pages! It caused all sorts of issues, so now, if you have type specific operations you need to specify the column's data type with the columns.type option.

ajmcgrail commented 2 weeks ago

Hey there Allan. I do specify the columns.type option as seen in the stackblitz, should be line 36.

AllanJard commented 2 weeks ago

Apologies - I see the issue. I'm just trying to work out what the best way to fix it is without causing the bugs that the fix that caused this to reappear!

AllanJard commented 2 weeks ago

I think I've addressed it okay in this commit. The change will be in the nightly build soon if you want to try it from there.

The change is to have server-side processing do type detection as soon as the data is loaded (which is similar to the client-side processing path now). I've also introduced an option to allow the disabling of auto type detection.

I'll do a release, probably at the end of the week with the change.

ajmcgrail commented 2 weeks ago

Hey there Allan. Really appreciate the super fast turn around! I'm hoping that will fix it for good. If the stackblitz works with your new commit, you can feel free to close this issue. Now that I know it's an actual issue and not me misusing DataTables, I'll go ahead and open another one if it comes up again and I'll make regression testing in our own stack to account for it once we're using the release. Thanks again for your time!