Hi everyone,
I’m following the servoy video “Drag and Drop within and between data grids” https://www.youtube.com/watch?v=_T7qEJfXEp8
and found that it does not work on my installation. The result is either nothing, nothing with warnings or an error of mismatched type.
The difference to the video that I noticed is that in the most recend version the parameter calls for an array and that the paramaeter is in plural with an “s” at the end:
* Called when a row is dropped as a result of a drag-n-drop.
*
* @param {Array<JSRecord>} sourceRecords
* @param {JSRecord} targetRecord
* @param {JSEvent} event
Leaving the paramaters as they are or changing them to whats in the video does not work.
The developer also gives out a warning:
The property sort_key is undefined for the type JSRecord
or an error
TypeError: Cannot call method "sort" of undefined
Does anyone have any clue on this?
Cheers
Alexander
Hi Alexander,
which version of Servoy are you on? I’m having problems getting this to work on Servoy 2023.03 NG Client. However, it seems that things are partially working in your case.
sort_key is the column you are using to sort the records. It may be called something different in your database table.
sort is a standard method on a foundset, so it sounds like you code is not correctly referencing the foundset of your grid component.
hope this helps,
Christian
Hi Christian,
I’m running 2024.9.1.4003 with NG-Grids on 2024.9.4
Naming of sort_key is correct in my database. Checked it before posting. Type is INTEGER.
Neither the sort method is working, nor simple caluclations like sort_key + 1
It seems like the function is not finding or using the foundset properly to add the correspoding record into (sourceRecords, targetRecord)
Is there a special way needed to place it in the parameter?
I tried so far:
@param {Array<JSRecord>}
@param {Array<JSRecord<db:/pqi/documents>>}
@param {JSRecord<db:/pqi/documents>}
You need to work with the array of source records and the target record.
The actual foundset is irrelevant here.
I would replace the placeholders with:
@param {Array<JSRecord<db:/pqi/documents>>} sourceRecords
@param {JSRecord<db:/pqi/documents>} targetRecord
@param {JSEvent} event
C
I tried this setting of the placeholders already, but nothing seems to work.
sourceRecords.doc_sortkey = targetRecord.doc_sortkey + 1;
``` like in the tutorial does not update anything.
application.output(sourceRecords.doc_sortkey,LOGGINGLEVEL.INFO);
sourceRecords is an array…
application.output(sourceRecords[0].doc_sortkey,LOGGINGLEVEL.INFO);
Thank you! That solved it…
But that also means that the video is outdated? Since the onDrop function now calls for an array and the video shows a JSRecord.