leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 213 forks source link

Can the Filters be dynamic, I mean to say written using ajax?? #206

Closed ddpdevang closed 9 years ago

ddpdevang commented 9 years ago

Can anyone help me in rewriting the library using ajax for automation search of the elements in the search.

And also in making the same responsive using bootstrap.

leikind commented 9 years ago

what help do you need?

ddpdevang commented 9 years ago

will need to rewrite all the grid filters to handle this dynamic thing through js so do we have a seperate repo for dynamic one or wcan you add me to it

leikind commented 9 years ago

well, I still don't get what you mean by "rewrite all the grid filters to handle this dynamic thing", but good luck. Should you have questions about the code I am at your disposal.

ddpdevang commented 9 years ago

The grid filter currently only filter if we click the filter button or a press enter button... It should dynamically filter rows as I am typing the search in textbox using ajax

leikind commented 9 years ago

any luck?

ddpdevang commented 9 years ago

What I wanted is this: http://wicegrid.herokuapp.com/auto_reloads3

Would have been better if the page would have not reloaded and it would have been using ajax.

But I think this might work for now ... and side by side keep working on making the same working using ajax...

Could you guide me on where I might code related to this... It would be great if you point me to that as then I can direct work on that bit rather than wasting time on searching other bits...

ddpdevang commented 9 years ago

Would have been even better if spinner(loading) is shown till the stuff is loading...

As the user cannot type continuous when it reload... after every keyword there is a interruption and the search box needs to be selected again when the page reloads

What should have happened here is only the stuff that should reload should be the grid... other stuff should be in the same state and control state change should be detected and acted according

leikind commented 9 years ago

the search box needs to be selected again when the page reloads

No. The input which causes a reload is focused on page load.

Could you guide me on where I might code related to this... It would be great if you point me to that as then I can direct work on that bit rather than wasting time on searching other bits..

What exactly would you like to know? I assume that you'll have to add an option for this, let the JS code know about it by storing this info in a 'data-' attribute, the JS code would then instead of reloading the page https://github.com/leikind/wice_grid/blob/rails3/vendor/assets/javascripts/wice_grid_processor.js.coffee#L17 submit an Ajax request and then replace the grid div with the response body. On the server side only the grid partial should be processed. The final trick would be to re-initialize all JS hooks for elements in the inserted HTML. Normally all init is in https://github.com/leikind/wice_grid/blob/rails3/vendor/assets/javascripts/wice_grid_init.js.coffee, but you'll have to make sure this only works for reloaded elements, and not in external filters.

leikind commented 9 years ago

Also, now when there are 2 grids on page, each one retains the state of the other by respecting and retaining all other page params. Implementing the same with 2 grids reloaded via AJAX will be a challenge.

In my mind Turbolinks already partially solve your problem