Topic: dbIndexToID(vrowid) does not work with sorted tablegrid

When I try to get the ID of the index item from a tablegrid that has been sorted it returns the wrong value. Is there a way that I can get the correct db ID of the grid item when the grid is sorted?

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi,
Dbindextoid doesn't normally present any problems irrespective of sorting.
Can you upload your project so we can better see what's happening?
Derek.

3 (edited by pwildman 2022-03-06 03:37:56)

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Derek, I tried to attach the project to this reply however, it doesn't post the reply with the file attached. The project is 64 megabytes zipped Is there another way I can send it to you?.  The tablegrid is on the first form that loads and the selected row of the tablegrid populates the fields to the right of the tablegrid.

4 (edited by pwildman 2022-03-06 03:45:54)

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Here is the project without the database file. I don't know if this will work for you. Let me know if it doesn't and how I can send the project to you.

Post's attachments

Attachment icon Minis V01_no-db.7z 288.55 kb, 143 downloads since 2022-03-06 

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi,
I had a quick look at your project(I chopped a load of things out just to make it easier for me to understand what was going on and because it wouldn't compile).
Not sure why you're using 'dbindextoid' or passing the record id to a variable - you always know the record id because you're clicking on each tabelgrid row manually and you're not performing any processing loops through the tablegrid. 
Try it with a simple 'select' using sqlexecute (if you want more information from the same record) or sub-selects if you are retrieving data from related tables (which is what your example is doing with 'creators', categories etc) or sub-sub-selects(I'm sure that's not the correct technical term!) if you are getting information from the whminiheight or whbasesize tables).
Have a look at the example and shout if something's not clear.
Derek.

Post's attachments

Attachment icon minis option 1.zip 355.33 kb, 105 downloads since 2022-03-06 

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Derek, thanks for showing me how to get the data into the text boxes. I also saw the reference table for and I like how you have that organized with all the reference tables.

I am now trying to populate the file (data) control named 'filemini' on the 'mini index' form with the folder path associated with the record. I am currently unable to figure out how to get that to work. I tried many things like 'LoadFromDatabase' command and sqlexecute command. I left the sqlexecute line in the script for the project. I zipped the project (your light version) , increased the version number and uploaded it here.

Thanks,
Paul

Post's attachments

Attachment icon minis option 1.35.7z 284.83 kb, 132 downloads since 2022-03-09 

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Paul,
Try it like this (see attached).
Derek.

Post's attachments

Attachment icon minis option 1.35a.zip 355.84 kb, 105 downloads since 2022-03-09 

8 (edited by pwildman 2022-03-11 02:01:44)

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Derek, is there a way to have it be a clickable link? So I can click it and open the folder?

I want the link to be something I can set for each record associated with the folder location which is different for each record.

Paul

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Paul,
I'm not sure what exactly you're trying to do.
1.  what exactly is it that you want to be a clickable link?  Which form and which field?
2.  on Form AddMini, what is the purpose of the field labelled 'Models Folder' (file_filelink)?  Is it that you want to create discrete folders where you can save your files (print ready file1, print ready file 2 and print ready base and image to) for each separate model?  If so, what added benefit does doing it that way bring?
Derek.

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Derek, on the add_mini form the 'Models folder' field is the folder where the models are located for that specific record. This allows me to click the 'Model folder' file link from the 'MiniIndex' form which opens windows explorer to the folder containing the model files.

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

This is useful project. Can you explain how could we get data from tablegrid to text box?

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Paul,
The way it's now working is within a holding folder called 'myminifiles', when a new 'mini' is added, the program automatically create a subfolder (named according to the new mini name) and any file that is selected from various locations is copied and stored in that sub folder.
When you click on the appropriate button on the 'miniindex' form, the relevant subfolder is opened and displays the folder contents.
A different approach might be to keep everything in the 'myminifiles' folder and prefix all the files with the relevant 'mini' name so they can be easily sorted / filtered.
Just a word of caution - your application is configured to use 'link files' rather than 'store files'.  This decision is usually determined by the likely number of files, photos etc you think you'll have and it is the good one if you are talking large numbers of files. 
However, be aware that when you use 'linkfile', any changes you make in your application don't automatically flow through to the files in any linked folder (eg if you delete an image associated with a 'mini' in your application, this won't automatically delete it from the 'copied to' folder;  you can write a script for it but it can get a bit convoluted!  Using 'store files', it is more 'self contained' within MVD and easier to manage.
There isn't a 'right' or 'wrong', it's purely a design decision based on your likely volumetrics.
Derek.

Post's attachments

Attachment icon minis option 1.36.zip 486.64 kb, 105 downloads since 2022-03-12 

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Derek, thank you for showing me how to copy files into my project.
Instead of copying files into my project, I would actually like to be able to link to the original file location? The scenario is: I have an existing folder structure for the files and I would like to be able to link to the existing file location(s) instead of copying them to the database folder.

Re: dbIndexToID(vrowid) does not work with sorted tablegrid

Hi Paul,
It might help to take a step back and use a simpler example than your actual project to explain what goes on.
Have a look at the screenshot in the attachment which is how the data is actually stored (I use SQLiteStudio - a free download;  it's invaluable in helping to understand your data (and therefore your program)).
1.  If you are using a type = 'Storefile', then the actual contents of your file / image would be stored in the fields 'writeup' and 'photo' (the red boxes) and the filenames would be null (the blue boxes)
2.  If you are using a type = 'Linkfile', then the actual contents are not stored in the database (which keeps it much more compact) and instead the location of the files are written to the 'writeup_filename' and 'photo_filename' fields (the blue boxes). 
2a. If you are using the 'copy to' option, then the path to the specified 'copy to' folder plus filename is saved in the 'writeup_filename' and 'photo_filename' fields. 
2b. If you are not using the 'copy to' option, then the original location + filename of the file is saved instead.
So, to answer your question, specify a type of 'linkfile' and leave the 'copy to' folder blank.  And as it is the same fields that contain the full path + filename irrespective of whether you use the 'copy to' option or not, your script should need little, if any, amendment.
I wasn't sure from your post if you simply want to open the folder where your files are held or whether you want to open the files themselves.   So, in the attachment, to cover both cases, clicking on a cell in the 'Write-Up Folder/File' column in the tablegrid will open the relevant folder, clicking on a cell in the 'Photo Folder/File' column will open the actual file (I always use an '*' in the column heading to denote to users that a column is 'interactive');  the syntax for both scenarios is in the script.
Finally, the data in the table obviously points to files on my machine so just delete the rows and replace them with data of your own.
Hope this helps,
Derek.

Post's attachments

Attachment icon mini3.zip 399.42 kb, 101 downloads since 2022-03-22