Issue #1776💬 AnsweredOpened February 6, 2019by shrnfnchr0 reactions

Add read-only trait for all controls

快速解答by artf

Create your own trait https://grapesjs.com/docs/modules/Traits.html

Read full answer below ↓

Question

We are using grapejs to create webpages. We are doing some back end manipulation of the json to link each child of the html (usually a row) to a record in our database. To that end, I've added a trait to every component called custom_pk. Upon saving the grapejs, I loop through the first level of components and add a record. Then I update the custom_pk with the primary key of the record in the database. The json has the appropriate trait and the html shows the custom_pk that I need. The last thing I'd like to do is to make the custom_pk trait read only while looking at the page through grapejs. Since it's updated on save (and since any change to the PK will break our implementation), I'd like for the user to not be able to change it. Here is my implementation: https://jsfiddle.net/shrnfnchr/ju8n1xdg/30 In order to see the custom field, I drag and drop a column 1 block onto the canvas, click on the row and then look at settings. I'm open to other ways to doing this.

Answers (2)

lock[bot]February 9, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.