nova-belongsto-depend icon indicating copy to clipboard operation
nova-belongsto-depend copied to clipboard

Ajax async searchable don't works

Open 4n70w4 opened this issue 5 years ago • 6 comments

            NovaBelongsToDepend::make(__('Organization'), 'organization', Organization::class)
                ->placeholder('Optional Placeholder')
                ->searchable(),

I get empty list and search don't work.

I can't use ->options(\App\Organization::all() ) because I have 10 000+ organizations. Rendering all list items slows down the browser.

4n70w4 avatar Nov 26 '19 12:11 4n70w4

Does anybody know what the status is, for this issue. I too will soon have an issue, where it's not feasible to use options() the way that it's currently implemented. Especially, when you expect +10.000 results to be returned.

aedart avatar Jul 21 '20 05:07 aedart

+1 for me. same issue. to many rows

gldrenthe89 avatar Oct 15 '20 08:10 gldrenthe89

Still no searchable() support?

simik-ru avatar Jan 20 '21 17:01 simik-ru

Feel free to make a PR. I will merge ist :)

orlyapps avatar Jan 20 '21 17:01 orlyapps

Fair point. Then, is there maybe an option for this component to depend on a standard Nova BelongsTo field?

simik-ru avatar Jan 20 '21 21:01 simik-ru

The performance problem with NovaBelongsToDepend->options() is the following:

List view

In the list view, for each field in each row, the field's meta data are returned from the server (via NovaBelongsToDepend::meta()). When using NovaBelongsToDepend->options(), all of the options are included in the meta data.

So when 25 rows are displayed in the list view, and each row has a single NovaBelongsToDepend field with 100 options, 2500 option arrays are included in the response.

Detail + edit view

When viewing the details or editing a record, all the options are returned with the meta data as well. Having 10.000 or even 100.000 entries slows down browsers considerably.

Possible workarounds and solutions

A workaround would be to use optionsResolve instead of options, but this does not work when editing a record: When clicking on the non-dependent NovaBelongsToDepend, only "List is empty" is shown.

Another solution could be to only include the options key in the meta data when editing a record, not when simply displaying it.

cweiske avatar Feb 21 '22 18:02 cweiske