106
Views
4
Comments
Editable column in Reactive
Question

Hey, 

I'm trying to develop a table with 1 editable column, like input text, and make it work just like excel, when user clicks on the input text, its editable, and when they click outside of that input, it will save what's on the input.


I maybe have found some post talking more or less about the same idea, but I didn't really understood what I need to do, if some could help me on how to achieve this. I would appreciate it a lot! Thanks!


2023-09-06 07-26-35
Sudip Pal

Hey Joao,

I have created a demo .Hope it will help you!

If you have some other requirement please let me know I will give you a good approach.

Thanks,

Sudip Pal

Sample3.oml
2022-12-30 09-46-57
Deepika Patel

Hi  Joao,

For instance, you have to edit the movies table:

1- First create a block with an input parameter of data type Movie. Drag Input text widget into that block and assign the value to that input widget to match the field—I'm currently using the title field as my example. And than save the record on the events of input according to your convenience(you can use onkeyup event).

2- Drag the block onto each cell and pass the value accordingly.

Regards,

UserImage.jpg
sabah gece

Hey there,

I've tackled something similar before. To create an editable column in a table like you described, you might want to consider using a combination of event listeners: one for focusing on the input (making it editable) and another for when the focus is lost (blurred) to save the input value.

Here's a basic idea:

  1. When the user clicks on the text input, you can use an onFocus event to enable editing.
  2. As for saving the data when the user clicks outside, you'll be looking at the onBlur event which is triggered once an element loses focus. Once this event is triggered, you can then capture the value inside the text input and save it.

If you're using a library/framework like React, Vue, or Angular, they all offer easy ways to bind these events to functions.

Here's a simple example with React:

function EditableCell({ value, onSave }) {

  const [inputValue, setInputValue] = useState(value);


  const handleBlur = () => {

    onSave(inputValue);

  };


  return (

    

      type="text"

      value={inputValue}

      onFocus={(e) => e.target.select()} // Optional: This will select all the text when focused

      onChange={(e) => setInputValue(e.target.value)}

      onBlur={handleBlur}

    />

  );

}


This is a very basic setup, and you might need to refine it further based on your needs. Let me know if you have any questions or if there's anything else I can help with. Good luck! 😊

UserImage.jpg
Puja Rani

Hi,

As per your used case, you can explore the data grid component. There are documents which will help you to understand better. 

However, just for your reference, I'm attaching OML with small demo. Hope this would help!

datagrid_sample.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.