Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: 1 [2]
  Reply  |  Print  
Author Topic: DISPLAY ARRAY and ON INSERT  (Read 4219 times)
Sebastien F.
Four Js
Posts: 545


« Reply #15 on: July 01, 2024, 09:54:49 am »

Hi Ben,

About docs you are absolutely right some hint was missing in the BDL doc.

We have now added a tip.

See attachment.

Seb


* screenshot-doc-1.png (118.88 KB, 1431x623 - viewed 556 times.)
Sebastien F.
Four Js
Posts: 545


« Reply #16 on: July 01, 2024, 09:56:07 am »

About the doc you are right, we have now added a tip, see attachment.

Seb


* screenshot-doc-1.png (118.88 KB, 1431x623 - viewed 581 times.)
Benjamin G.
Posts: 130


« Reply #17 on: July 02, 2024, 02:54:55 pm »

Remarks ...

The sample proposed by Reuben was the solution that we've initially programmed but this is not really a good solution because of sort problem ...
If you try that cod after the "on action my_insert" is validated and the array is sorted the new row "dissapear" from the screen and for the end user is very strange ...
With the "ON INSERT" the row stay at the position inserted until the display array is refreshed


Regards
Reuben B.
Four Js
Posts: 1119


« Reply #18 on: July 03, 2024, 12:53:59 am »

Remarks ...

The sample proposed by Reuben was the solution that we've initially programmed but this is not really a good solution because of sort problem ...
If you try that cod after the "on action my_insert" is validated and the array is sorted the new row "dissapear" from the screen and for the end user is very strange ...
With the "ON INSERT" the row stay at the position inserted until the display array is refreshed


Regards

My example probably should have a DIALOG.setCurrentRow("scr", r) at the end to set the current row in the array to the row that has just been inserted.

However you said "... and the array is sorted ...".  I would be curious as to how at this point you do your sort.  Is the user clicking slowly twice on the header to redo the sort, or are you calling array.sort() ?

You should also note  the existence of an fglprofile entry "currentRowVisibleAfterSort" https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_fglprofile_004.html.  Default value is false.  If you set this to true, add the line above to set the current row to the line just added, then after inserting the row if you redo the sort by clicking slowly twice on the column header, then I think you will see what you want to see.

If you have explicitly added an array.sort(), then you might not get results you anticipate, for the same reasons that you use DIALOG.insertRow and not array.insertElement.  Perhaps we should have a DIALOG.reapplySort so that the user does not have to slowly click twice on the header ...

Reuben





Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Benjamin G.
Posts: 130


« Reply #19 on: July 24, 2024, 02:12:34 pm »

Hi,

I don't understand why with a DISPLAY ARRAY and on action handler using DIALOG.insertrow() just after arr_curr()/scr_line() returned values are different from DIALOG.getCurrentRow() and DIALOG.arrayToVisualIndex().
There is always a gap from 1 between the values ...

eg : if the cursor array is on the line number 3 arr_curr() and scr_line() return 3 but getcurrentrow()and arraytovisualindex return 4 after the insertrow()

is there any explanation about this difference ?

Regards
Sebastien F.
Four Js
Posts: 545


« Reply #20 on: July 26, 2024, 10:21:48 am »

Benjamin,

Please provide a code example next time.

If you want to implement your own action handler to insert a row, you should do following:

Code
  1.        ON ACTION myinsert
  2.           LET x = DIALOG.getCurrentRow("sr")
  3. display "insert row: curr = ", x
  4.           CALL DIALOG.insertRow("sr",x)
  5.           CALL DIALOG.setCurrentRow("sr",x)              -- MUST SET THE NEW CURRENT ROW!
  6. display "after insertrow()"
  7. display "  arr_curr()           = ", arr_curr()
  8. display "  scr_line()           = ", scr_line()
  9. display "  getCurrentRow()      = ", DIALOG.getCurrentRow("sr")
  10. display "  arrayToVisualIndex() = ", DIALOG.arrayToVisualIndex("sr",DIALOG.getCurrentRow("sr"))
  11.  

However, why are you doing this?

Is ON INSERT of DISPLAY ARRAY not good for you?

Please explain the reasons why you want to write your own action handler to insert rows.

Seb
Benjamin G.
Posts: 130


« Reply #21 on: July 26, 2024, 11:15:22 am »

Hi Sebastien,

The reason of using a custom action is that the user can choose between "insert one" or "insert multiple" records in the array ...
It would be nice that if we could call an "on action" programatically

eg. :

Display array .....
   on insert
       code ....
   on myaction insertone
     execute "on insert"
   on myaction insertmultiple
     while not stop
        execute "on insert"
     end while
end display

i will try with the "setcurrentrow" after insertrow ... but it seems to me not logical


regards
Benjamin G.
Posts: 130


« Reply #22 on: July 26, 2024, 11:20:51 am »

Hi,

calling setcurrentrow after insertrow work's ...

regards
Pages: 1 [2]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines