orlyapps / nova-belongsto-depend

Larave Nova BelongsTo Field with Dependcy
MIT License
182 stars 65 forks source link

Ajax async searchable don't works #53

Open 4n70w4 opened 4 years ago

4n70w4 commented 4 years ago
            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.

aedart commented 4 years ago

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.

gldrenthe89 commented 4 years ago

+1 for me. same issue. to many rows

simik-ru commented 3 years ago

Still no searchable() support?

orlyapps commented 3 years ago

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

simik-ru commented 3 years ago

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

cweiske commented 2 years ago

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.