[Question] Add read-only trait for all controls
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)
Create your own trait https://grapesjs.com/docs/modules/Traits.html
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.
Issue #1888
[Question] Add custom html inside canvas
Hi there, I'm using grapes to export a custom json with all the information i need, instead of HTML and CSS. For doing that I'm parsing the...
Issue #1875
[QUESTION] ID changes when importing html or passing html in components prop in config.
Hi, I built a component and block that I can drag and drop in the canvas. My issue is that some styles rely on the ID. I know this might no...
Issue #1966
[QUESTION] Loop over all components
Hi all, I want to create a socket for every button that I add to the canvas. This is working just fine. However, when I reload (using stora...
Issue #1897
[Question] view vs code
Hello...and sorry for my english! First of all, congratulations for this fantastic framework. I'm trying to use GrapeJS to create my own wo...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.