Gridview with CRUD Options (MySQL)


#21

You have an error in eithor your data.txt or the update code you are using. It throws an error: "Error: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect integer value: 'Rishan' for column 'lastname' at row 1"

You can't define a colum as 'int' and then expect to insert text into it.

Also, you define several rows as 'int(255)' why? Do you realize that that says you want to store 255 digits?

INT(size) -2147483648 to 2147483647 normal. 0 to 4294967295 UNSIGNED*. The maximum number of digits may be specified in parenthesis

so the maximum size in parenthesis can only be 10.


#22

There are two tables called test and lastname. Table test consists of id, name, lastname and code columns. Table lastname consists of id and lastname columns. I want to store the data into test table, but I want the lastname dropdown field options coming up from lastname column (lastname table). I just would like to save the id of the lastname table into test table.

That int(255) came automatically once I created the column. If 10 also fine.


#23

So if I understand you, you want all last names stored in the table called 'lastname' while in the table called 'test' the column you call 'lastname' should actually be 'lastname_idx' to show that it is just an index into the 'lastname' table. It will only contain the index value (a number) of the name in the 'lastname' table. Is that correct?

If so, you need to correct your update code to move the id not the lastname feild into the lastname of test, but then how is your add suppose to work? How will someone add a new last name into the table?

I might suggest you copy this Gridview code out and put it in some straight HTML files and get it to work, before trying to get it to work in Node-RED.


#24

@zenofmud, I would like to make the lastname column data of lastname table as the dropdown options on Gridview's lastname field. The id of lastname table should be added/updated to the lastname column of test table once I perform add/edit on Gridview (according to selected lastname).

It's already too long I created this topic, but no solution for this till date. I'm pretty sure @shrickus able to provide the solution for this. @knolleary, I need your help as well here.

Thanks for helping. :slightly_smiling_face:


#25

@rishanaziz Let me pose a scenario for you.

I'm told to add a new person, 'John Smith' with code '888' to the table. I go to the table and press the plus (+) button. I can now enter first name 'John' and the code, but since you want lastname stored in a different table, how do I add 'Smith' to that other table?

This is NOT a Node-RED problem, your underlining code is not working. I suggest you eithor

  1. change the requitement and store the actual lastname in the test table or
  2. get it working outside of NR so you have an idea of how to get this scenario with Gridview to work.