DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • DZone Community Awards 2022
  • An Introduction to Type Safety in JavaScript With Prisma
  • How to Build a Concurrent Chat App With Go and WebSockets
  • Building AMQP-Based Messaging Framework on MongoDB

Trending

  • How to Create a Successful API Ecosystem
  • Monoliths, REST, and Spring Boot Sidecars: A Real Modernization Playbook
  • Build a Simple REST API Using Python Flask and SQLite (With Tests)
  • What’s Got Me Interested in OpenTelemetry—And Pursuing Certification
  1. DZone
  2. Data Engineering
  3. Data
  4. Working With ArrayDataProviders Using JavaScript Functions in Visual Builder

Working With ArrayDataProviders Using JavaScript Functions in Visual Builder

Learn how to add additional processing/updates on all the records you're storing in an ADP.

By 
Shay Shmeltzer user avatar
Shay Shmeltzer
·
May. 14, 19 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
14.6K Views

Join the DZone community and get the full member experience.

Join For Free

Storing data in ArrayDataProviders (rather than SDP) is useful whenever you want to further modify the data on the client side — for example, if you are looking to create updatable tables in your UI. A common follow up question is, "how can I do additional processing/updates on all the records I'm storing in the ADP?" This is what this post is about.

Since the records are now stored on the client-side, you can access them through JavaScript. You can, for example, write a page level module function to loop over the set of records and modify them. For example, in the video below I'm using this little function to raise the salary of all the employees:

PageModule.prototype.arrayModifier = function(array){
  console.log(array.length + " is what we got")
    for (var i = 0; i < array.length  ; i++ ) {
      array[i].salary = array[i].salary+2;
      console.log("salary after " + array[i].salary);
  }
  return array;
}

Into this function you'll pass the array of data from the ArrayDataProvider — you can do this in the parameter mapping of the function pointing to the data object like this:

Data array
Data Array

Once your function finished its processing of the data, you'll want to update the ArrayDataProvider back to reflect the changes you made. To do this you can use the action called "Fire Data Provider Event." This function has the option to mutate events (update, insert, delete). You can read the doc about this and other actions parameters here. For the update, you simply need to provide the array of updated data like this:

Updated Data
Updated Data

That's it. You can see all the pieces of this process working together in the video below:


Database JavaScript Data (computing)

Published at DZone with permission of Shay Shmeltzer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • DZone Community Awards 2022
  • An Introduction to Type Safety in JavaScript With Prisma
  • How to Build a Concurrent Chat App With Go and WebSockets
  • Building AMQP-Based Messaging Framework on MongoDB

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!