neoTableDeleteRowByID - Forum

Forum Navigation
You need to log in to create posts and topics.

neoTableDeleteRowByID

Hi @luishp, I tried using neoTableDeleteRowbyID function and it doesn't delete the selected item. However, if I use ArrayDelItem, it works fine...

Below is my code:

ParseJSON "[neoTableRowString]" [tt]
SetVar [sid] "[tt('id')]"
.neoTableDeleteRowById "ViewsContainer" [sid]
ArrayDelItem [mydata] [sid]

Am I calling the neoTableDeleteRowByID correctly rather than using ArrayDelItem?

@ronnie please provide a complete sample so I can take a look at the table.
Thank you!

asmat has reacted to this post.
asmat

Hi @luishp, Attached is a sample demo. Funny thing is I was able to retrieve the ID using the commands stated,  but now I couldn't identify the ID selected with this 'cleanup' demo.

Questions:

  1. How to delete Row by ID?
  2. How to do a Search via textInput1 entry?
  3. How to correct the ID which doesn't work now?
  4. Any way to streamline the Insert data strings?

Hopefully you can check and correct them so that others could refer to this sample as a demo for simple LocalStorage database..

 

Uploaded files:
  • You need to login to have access to uploads.

Hi @ronnie,

I have just take a quick look to you sample. At first sight, although you have defined the id field within the JSON it has not been included into neoTable. The id field should be a numeric unique value and must be part of the neoTable data in order to work:

neoTableSetColumn "ViewsContainer" 1 "id" "ID" "40px" true false true ""
neoTableSetColumn "ViewsContainer" 2 "name" "Name" "80px" true false true ""
neoTableSetColumn "ViewsContainer" 3 "gender" "Gender" "10px" false false true ""
neoTableSetColumn "ViewsContainer" 4 "dob" "Birthday" "30px" false false true ""

 

Hi @luishp, while the sample neoTableEditor shows DELETE buttons, they're SQL instructions which is different as  the demo does not illustrate the use of neoTableDeleteRowById function. Or for that matter, the neoTableGetSelectedId.

I might have missed something but tried various means, I could not delete the row by id, even using commands like

neoTableGetSelectedId "ViewsContainer" [idnum]
neoTableDeleteRowById "ViewsContainer" [idnum]

 

OK, I found a solution by  not using the reserved word "id" by using "idn" instead. This means using commands like:

neoTableDeleteRowsByValue "ViewsContainer" "idn" "[selectedID]"

works fine...

 

Hi  @luishp,   Another issue.. even running the NeoTable demo, using console checking.. when clickinbg on a row, the variable status for neoTableRow is showing "[object Object]". is there away to identify the selected row  automatically via the eventManager subroutine? I tried adding a separate call to an external function putting scripts like:

StringifyJSON [neoTableRow] [s1]
beginJS
  var obj = JSON.parse($App.s1);
  $App.selectedID  = obj.idn;
endJS

Even adding a simple jsalert in the "click" section shows "[object Object]" result...

   If [neoTableEvent] == "click"
      SetVar [thisEventData] "[thisEventData][neoTableField]"
      StringifyJSON [neoTableRow] [neoTableRowString]
      SetVar [thisEventData] "[thisEventData]<br/>[neoTableRowString]"
      jsalert "[neoTableRow]"
   EndIf

How do I retrieve the selected value upon user clicking on the record item using neoTable functions directly and calling a subroutine for follow-up action... without user clicking on a separate button to access the ID manually? For example,when I replaced the jsalert script with a subroutine, it doesn't execute...

solving the problem myself... after much testing, one method I did was to include whatever scripts I want to execute into the ViewsContainer code area. Definitely not the best but workable for now, unless there is a way to execute a script direct from the eventManager section..

Hi Ronnie.

I am having the same issue as cannot get the selected field in the table to show. In edit mode where you can set a selectable field when you click on it you still don't seem to be able to get the record id selected. neoTableGetSelectedId does not seem to work. I have the primary unique id field as the selected field too. It is showing in the table as a column next to the selectable one to show its there.

I have tried all combinations of the plugin commands to get an indication of the selected record in a table but nothing works.

Did you manage to find away to get this to work?

@ronnie  Hi Ronnie

Why do not use neoTableSetSelectColumn ?

pnNew

neoTableSetSelectColumn "ViewsContainer" 1 "id"
neoTableSetColumn "ViewsContainer" 2 "id" "ID" "80px" false false false ""
neoTableSetColumn "ViewsContainer" 3 "name" "Name" "80px" true false true ""
neoTableSetColumn "ViewsContainer" 4 "gender" "Gender" "10px" false false true ""
neoTableSetColumn "ViewsContainer" 5 "dob" "Birthday" "30px" false false true ""

pbDelete

you do not need to parse [neoTableRow]

SetVar [sid] [neoTableRow('id')]
jsAlert "Row to be deleted: [sid]"
neoTableDeleteRowById "ViewsContainer" [sid]
StringifyJSON [mydata] [myitems2]
SetItem "mylist" [myitems2]
. reload the data
GetItem "mylist" [myitems2]
ParseJSON "[myitems2]" [mydata]
.refresh updated data to table
neoTableLoadData "ViewsContainer" [mydata]