Coder Social home page Coder Social logo

marceswan / dynamicfieldslwc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from seanpat09/dynamicfieldslwc

0.0 0.0 0.0 785 KB

A dynamic multi-line input table using LWC

License: MIT License

JavaScript 77.80% Apex 2.43% CSS 0.24% HTML 19.53%

dynamicfieldslwc's Introduction

Dynamic Multi Row Editable Tables using LWC

Quickly define an input table with columns that you can add rows to. Great if you need to capture multiple rows of input that are not necessarily mapped to an SObject

Example Multi Edit Table

Installation in a Scratch Org

See https://trailhead.salesforce.com/en/content/learn/projects/quick-start-lightning-web-components to get set up with LWC.

Clone this repository and open in Visual Studio Code

Authorize a Dev Hub

  • In Visual Studio Code, press Command + Shift + P on macOS or Ctrl + Shift + P on Windows or Linux.
  • Type sfdx.
  • Select SFDX: Authorize a Dev Hub
  • Log in with credentials for your Developer Org with Dev Hub enabled
  • Click Allow.
  • After you authenticate in the browser, the CLI remembers your Dev Hub credentials and you should a success message in the Output window in VS Code

Create a Default Scratch Org

  • In Visual Studio Code, press Command + Shift + P on macOS or Ctrl + Shift + P on Windows or Linux.
  • Type sfdx.
  • Select SFDX: Create a Default Scratch Org....
  • Press Enter to accept the default project-scratch-def.json
  • Press Enter to accept the default scratch org alias
  • Press Enter to accept the default 7 days scratch org duration
  • Be patient, creating a scratch org can take a minute. A success message will appear in Output window in Visual Studio Code once complete with a message like Successfully created scratch org...

Push Source to Scratch Org

  • In Visual Studio Code, press Command + Shift + P on macOS or Ctrl + Shift + P on Windows or Linux.
  • Type sfdx.
  • Select SFDX: Push Source to Default Scratch Org
  • Since is this is the first time your pushing your source code to your scratch org, this may take a minute. When complete, you'll see the results in the Output window in Visual Studio Code.
  • This is the same command you'll use to push any changes you make your source code. This command does a diff and only pushes code that has actually changed, so subsequent pushes will be faster than the initial one.

Usage

Use the web component as follows:

<c-multi-edit-table 
    column-list='\[{ "label" : "Name", "apiName" : "Name"} , { "label" : "Email", "apiName" : "Email" }, { "label" : "Phone", "apiName" : "Phone" }]'
    title='Attendees'>
</c-multi-edit-table>

column-list is a JSON string that will be parsed to create the columns of the table. Label will appear in the header of table and apiName will be used for the keys of the object when fetching data from the table

title is used as the title of the table

use the web component method retrieveRecords() to get a list of objects built from the inputs of the table. Order is not preserved. Your implementation will need to handle sending this data to your Apex controller. See demoComposition for an example.

Running tests

First install node modules. Run npm install at the base of your app. Once that is complete run npm run test:unit. There are a few issues with lwc-jest and Windows, I was only able to get the tests working in Windows Subsystem for Linux (WSL)

dynamicfieldslwc's People

Contributors

seanpat09 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.