1 (edited by v_pozidis 2023-10-24 21:29:06)

Topic: Delete secected rows

Hi all, in my small software I have a Boolean (tsek) that will not allow the selected row to be deleted. What I  want is a script that by pressing the Button Selected it will change all the selected records to changed from False to true, And in the Button Delete Selected to do exactly what it’s says, to multidelete the selected records.

Post's attachments

Attachment icon testcheck.zip 326.26 kb, 51 downloads since 2023-10-24 

Re: Delete secected rows

here's one.

Post's attachments

Attachment icon testcheck2.zip 550.47 kb, 81 downloads since 2023-10-25 

brian

Re: Delete secected rows

Thank you for the example.  I do not understand correctly the,  ID_IDX = 4; // index of the id in grid.  In the example it is in the first place in the Grid

brian.zaballa wrote:

here's one.

4 (edited by brian.zaballa 2023-10-26 05:52:23)

Re: Delete secected rows

it is a constant. stores value(in that case, an integer) such as integer, string, real, etc...
it is accessible all through out your script in any function or procedure.

i want storing such value in the constant so that later on, i can only set it in the top.

4 is the column index on the grid. so say for example you change the arrangement of the grid, like adding a column before the current index 4, all you have to do is change the constant value, then all is well.

check that i used the constant ID_IDX in different procedures

Form1_Button5_OnClick
Form1_TableGrid1_OnChange
Form1_Button4_OnClick
Form1_Button6_OnClick

I could just set it to its corresponding value(4) like for example

SQLExecute('DELETE FROM Names WHERE id='+Form1.TableGrid1.Cell[4,i].AsString);

and in the other procedure but, then, when you decided to re-arrange your grid (like adding a column), what will happen is you will have to look on all the procedure with that index 4 and a big chance(this happens a lot) to omit some value that needs updating and sometimes it'll not throw an error, but will give an unexpected or unnoticeable output and will eat your time to just looking for that code/s.

Check on the Settings of the TableGrid1, notice that I added Names.id right after Names.tsek  it is at 5th column (index:4)

brian

Re: Delete secected rows

Wow, my mistake. I didn't read it correct. Another Question: If there is no Boolean type and there is a combobos to choose the records you wanna delete is it possible ?

Re: Delete secected rows

Hi V_Pozidis, Hi Brian,
Some time ago I had a quite similar requirement (attached is a simplified version).
Users could 'mark' a record for deletion but only the supervisor could actually perform the deletion (individually or in bulk) which was done on a weekly basis once the list had been checked.
To mark a record for deletion,  just click on the appropriate cell in the tablegrid.
If you are logged on as a supervisor, the 'deletion' button is enabled otherwise the 'deletion' button is greyed out.
Valid user ids are admin (password admin) and xx (password xx).
Maybe this gives you some ideas?
Regards,
Derek.

Post's attachments

Attachment icon bulk delete.zip 444.3 kb, 65 downloads since 2023-10-26 

7 (edited by v_pozidis 2023-10-26 12:38:32)

Re: Delete secected rows

Hi Derek. Yes that's the one. Thank' s Derek, your help is always the solution of many problems.
Because I have a project that I do not wont to add records in the tables , can I use the #checkbox in the Tablegrid and when this is true so all the records would be deleted ? Something like this   sqlexecute('delete from people where #checkbox = True');----I know this script do not work but is there a solution not to add records in a table ?