LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Table, edited cell reference

Solved!
Go to solution

I'm curious if I am either missing something or if anyone has a more eligant way to capture the last edited cell in a table...

 

I thought this was going to be an easy Value Change event using either the ActiveCell>CellPosition node or the EditPos.  However, I found various problems relating to mouse click / key press combinations.  The cell position did not seem to be correct (almost like it had an offset).  The Edit position was correct while entering text, but as soon as a mouse click/Tab/Return/Enter event occured, the edit position changed to the new cell.  I then noticed that the Value change event seemed to happen after my key down or mouse click events (although I did not check if that had to do with the order of my events structure).

 

So, I feel I came up with a rather convoluted -- although successful -- method for achieving my goal.  I had to capture a reference to the row/column cluster with the key down event (while ignoring Tab/Enter/Return key presses).  Then I used this reference to set an active cell on a value change event.  This way, it only needs to run the more in-depth code once.  This efficiency will be more important when performing more involved sequences with a cell change.

0 Kudos
Message 1 of 7
(4,244 Views)
Solution
Accepted by topic author JFleck

I've always done it like this:

Edited Cells in Array.PNG

Compare OldVal to NewVal. For every Not Equal cell, output that cell's coordinates. You can use these coordinates to set the active cell if you want. This is within the Value Change event so this only occurs upon value change of the table, not when the mouse clicks. Is this what you're looking for?

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 2 of 7
(4,233 Views)

That looks like a much better solution.  Much appreciated!

0 Kudos
Message 3 of 7
(4,224 Views)

I had to tweak this method slightly so I figured I would post what I am doing.

 

Since my method for the user changing the table is limited to one cell at a time, I only want to output the location of the changed cell.  James' method got me very close but didnt work for me because it output a 0,0 for each row that did not have a value that changed.  0,0 is a valid cell location to evaluate for changes and so I wouldnt know (programatically) if the upper left cell actually changed or not.  Of course, if the entire output array is all zeros and I know the Value Change event triggered this function, then I could assume that cell 0,0 must have changed.  But I still would need some additional code...

 

Instead, I chose to tweak James' method very slightly by adding an Or Array Elements function on each row of data and changing the outer tunnel to be Last Value and conditional.  This ignores any rows that do not have a changed cell and thus returns only a 1D array with the two values that indicate the changed cell Row/Column location.

 

Capture.PNG

 

The next problem I found was that if the user enters a value on a new row (which is allowable and expected in my program), there is no OldVal to compare against and so the "notequal" function truncates the boolean array.  I now need to build in some sort of check for this.  Still, this method is far better than my original.

0 Kudos
Message 4 of 7
(4,168 Views)

@JFleck wrote:

I had to tweak this method slightly so I figured I would post what I am doing.

 

Since my method for the user changing the table is limited to one cell at a time, I only want to output the location of the changed cell.  James' method got me very close but didnt work for me because it output a 0,0 for each row that did not have a value that changed.  0,0 is a valid cell location to evaluate for changes and so I wouldnt know (programatically) if the upper left cell actually changed or not.  Of course, if the entire output array is all zeros and I know the Value Change event triggered this function, then I could assume that cell 0,0 must have changed.  But I still would need some additional code...

 

Instead, I chose to tweak James' method very slightly by adding an Or Array Elements function on each row of data and changing the outer tunnel to be Last Value and conditional.  This ignores any rows that do not have a changed cell and thus returns only a 1D array with the two values that indicate the changed cell Row/Column location.

 

Capture.PNG

 

The next problem I found was that if the user enters a value on a new row (which is allowable and expected in my program), there is no OldVal to compare against and so the "notequal" function truncates the boolean array.  I now need to build in some sort of check for this.  Still, this method is far better than my original.


Check compare the array sizes to detect an addition or deleation.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 7
(4,162 Views)

Ben,

 

I am currently comparing the two array sizes (old & new) seperately and evaluating if they are not equal (using aggregates mode).  If not, then I evaluate the new section for any non-zero value and assume this as my edited cell.  Is this how you meant or am I missing a direct "compare array sizes" function?  (I'm using 2013)

 

(Sorry, for some reason my image would not upload)

0 Kudos
Message 6 of 7
(4,158 Views)

Basically yes.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 7
(4,156 Views)