Drupal Views Ajax refresh rows - ajax

I have some view (Views 2 - list of invitations, table style) which uses embedded forms to edit records directly in view rows.
I am using ahah to change values in records. What I need is to refresh all records dynamically (some calculations) after I change some checkboxes.
Is there any way to refresh view using Ajax?
To trigger reload table rows only form the code?
I suspect it must be some way (some command) as there is a Use Ajax option in views for sorting tables, etc...
Any hints would be much appreciated

In basic settings there is the 'use ajax' option which :
If set, this view will use an AJAX mechanism for paging, table sorting and exposed filters. This means the entire page will not refresh. It is not recommended that you use this if this view is the main content of the page as it will prevent deep linking to specific pages, but it is very useful for side content.
you may find the module Ajax Views Refresh useful

Related

Updating ag-grid with new data after new table load with React

I'm using React and I have a navigation component that updates a Redux table state. Based on the table chosen in the navigation, I need the ag-grid to update accordingly.
I have six tables. Three of them have the same column definitions. I'm currently using onNewColumnsLoaded to refresh the data, but because three of the tables have the same column definitions, nothing's loading. I've tried onColumnEverythingChanged and other column options, but again because the columns are the same nothing is happening.
I've tried rowDataChanged, rowDataUpdated, and componentStateChanged, but those refresh the data if I'm scrolling or filtering, so those are not acceptable options.
I've taken a look at this answer, but it's using plain javascript, and this one has a problem in the css, not in the javascript.
What's the best way to have the grid update programmatically based on Redux state variables?
You can check to use immutableData with directly udpate the rowData:
getRowNodeId
method should be implemented as well.
Check the doc for more detail.

DataTables - Specify page size on server side

When using DataTables, how can I control page size on the server-side? I want to take advantage of bult-in navigation buttons (prev, next etc.), but don't want clients to be able to dictate page size.
The only option I see is pageLength which controls page size from client's end, which defeats the purpose in my case.
This is Laravel application and I'm using Yajra package (DataTables as a Service) implementation. Note that I can't use Eloquent's built-in pagination because then I'll have to manage navigation myself and will also need to disable DataTable's own navigation because that one depends on pageLength.
A good way is to remove the present page size in the datatable by adding paging to false on data table options.
Then u can do pagination by simply add laravel pagination class when dragging data from your models. E.g
$all_items = user model::paginate($page_size,['*'],'page_no');
The last variable of the paginate method is just indicating the parameter name of the page no. Useful when you have more than pagination in a page. It can be changed to whatever unique value u like.

Django one page website with lateral navbar

My current setup looks like this(from here, mostly):
This is the result of my home view. What I intend on doing is keep those 2 sidebars in place and refresh only the content part.
My question: What is the obvious solution to this in django?
From what I read so far it seems to be using Ajax to see what exactly the user clicks on the sidebars and return only a part of the HTML which would be the div where all the content is. (or return a JSON and refresh that div depending on the JSON values?)
I need to avoid refreshing the entire page, it seems useless. I could forget about Ajax and just run on separate views but I would have to pass every time a context variable to populate the sidebars depending on the user and this seems to be an overkill.
Even more specific: On the push of a button on the navbar now that is a href- links to another page. In order to make it refresh only part of the page what should the button trigger? Should it trigger a jquery function or is there a better option?
If your concern is only about left sidebar calculations, then you can go with caching
Django allows to cache part of page - sidebar is ideal item for caching. If sidebar is different for users (I see at least playlists menu item), then it's also possible to implement fragment caching per user, check Vary on headers part of documentation.
Using ajax will complicate your development process - generate html/json encode/render it on user side, etc, etc. And now almost no one uses django in this way. If you want pure single page application, then I suggest you to take a look at some javascript framework like Angular, Vue or React + Django API backend.

Is it better to use ajax pager or plain post back?

I'm creating a pager for grid data. Basically, I can do it in two ways: when user clicks on a page number, load grid data by using ajax call, or, post back to server (GET or POST) and use query string parameters (or POST variables) to know which page to display. With both methods, sorting of grid items must be persisted.
What is better considering performance and SEO and why?
-- UPDATE --
I need pros and cons for both approaches. I know this is somewhat discussion rather than question, but I need your experiences.
Also, when using ajax, it is not only SEO that I'm wondering about. Will browser's back button behave as expected?
Why not do both.
Have the grid load with SEO friendly anchor GET links then implement some JavaScript to convert them to AJAX calls.
People without JavaScipt (like spiders) can then still navigate around while fancy people will get the enhanced AJAX experience.
With AJAX you can alter history and make the back button work as expected.
Your grids are loaded via AJAX? and you are worried that SEs won't pick them up?
What you can do to get your content indexed is to:
use segmented URLS like CodeIgniter and WordPress instead of query strings. SEs will (supposedly) see them as subfolders.
Instead of loading everything in AJAX, grid data can also be represented as tabular data. What you can do is to load the tabular format for the static page, then with JS, you can replace the table with your grid.
say for example i want to load sports stats, mysite.com/sports/stats should give me tabular data when JS is off, and if i had JS, that data is replaced with the grid.

How to Handle Mutiple Model Bound Forms

I am buiding a UI screen for editing the details of an Ecommerce Order. The model for my view (OrderModel) has everything I need (in properties that are also ViewModels), but the UI isn't designed to be able to edit all of it at once.
For example, one part of the UI is for customer data..another for order details, and another for tracking information, each having their own "Save" buttons.
I realize that I could use one giant form and use hidden form fields to populate the non-editable fields, making each "Save" button post all the data, but that smells bad.
I'd like to segment the editable chunks into smaller ViewModels that are posted and validated individually while retaining the strong typing but I'm unsure of how to achieve this in MVC3. Will I need partial views that are called from the primary view?
FYI, I'm using ASP.NET MVC 3 with Razor syntax and client side FluentValidation.
Partial Views are a good solution. You can pass different ViewModels to each partial view. But if only sections of the overall view are updated at a time I would not do a post back on the whole page. Instead I would use Ajax calls using JQuery/Javascript to update the individual information back to the controller. I would also look into something like Knockout.js to handle the data binding on the page.

Resources