Gridview with CRUD Options (MySQL)

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.

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.

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.

@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:

@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.

Hi all,

I accomplished my objective using jqGrid.

I added the flow to the following link:

https://flows.nodered.org/flow/9a57908f031def68946f6bdf4cfb94a4

2 Likes

It's nice of you to provide a flow, but without the underlining database tables it is not very helpful as an example.

Bravo......Very helpful and useful grid.....Thank you.

1 Like

You're welcome