artem

artem

Has anybody tried integrating an advanced JavaScript data grid with dynamic data fetch to Live View?

Hi all

The problem
I am into building a data intensive app in LiveView. It is basically a smart analyzer of customer feedback: use AI to parse out opinions and topics, then aggregate, chart, present it visually.

Naturally, a bit part of design is going to be a large data grid for the feedback topics, statements, various metadata (e.g. date or app version) with pagination or ideally even endless scrolling.

This seems to be a quite good fit for live view, some elixir courses even teach you how to build paginated grid in one of the first lessons.. yet it’s still would be a home grown solution.

Looking for a solution
It would be wonderful if I could use some of the advanced JS data grids out there such as AG-Grid or ReactTable. Then you’d be able to get for free a lot of battle-proven magic such as easy column reordering, filtering, UI for endless scrolling or unwrapping rows to details as in screenshot.

In theory if such grids could use some DOM nodes for data LiveView could relatively easily supply that when needed and adjust queries based on callbacks (e.g. when button for sorting is clicked), but that’s theory :slight_smile:

Has anybody done it in practice? Is it really possible to connect a JS-native data grid with lots of JS-side magic with a LiveView data supply?

Most Liked

sb8244

sb8244

Author of Real-Time Phoenix

Thanks for the shout-out. As a note I really liked the hybrid react+LiveView approach and would do it again.

I don’t feel any attachment to having a pure LV system. I’d rather pick the thing that’s going to work best for what I want, especially if I don’t need to create it from scratch.

LiveView hooks give you everything you need to mount react, so check out that post to see how I did it.

NduatiK

NduatiK

You can also have a look at Kino’s DataTable implementation. They use:

  1. LiveView to load the data - SmartCell
  2. React + Glide Data Grid to render out - JS

Looks good I think,


This Elixir + this React lets you update the rendered data

codeanpeace

codeanpeace

Off the top of my head, there’s no reason it wouldn’t be possible. LiveView Hooks make all sorts of integrations possible. The question, as always, becomes whether it’s the right thing to do given your unique set of circumstances i.e. requirements, constraints, and tradeoffs.

The LiveView docs are great and especially relevant is the section on DOM Patching & temporary assigns

A container can be marked with phx-update, allowing the DOM patch operations to avoid updating or removing portions of the LiveView, or to append or prepend the updates rather than replacing the existing contents. This is useful for client-side interop with existing libraries that do their own DOM operations.

The “ignore” behaviour is frequently used when you need to integrate with another JS library. Note only the element contents are ignored, its attributes can still be updated.

… as well as the section on JavaScript Interoperability.

There’s also a helpful article written by the author of Real-Time Phoenix @sb8244 React in LiveView: How and Why? that establishes some useful guidelines when working with React within LiveView.

And another potentially useful resource includes phoenix_live_react, a helper library for easily rendering React components within Phoenix LiveViews.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement