View Issue Details

IDProjectCategoryView StatusLast Update
0004231JEDI VCL00 JVCL Componentspublic2007-10-12 08:46
ReporterAriochAssigned Toobones 
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
PlatformDelphi 5u1 EEOSOS Version
Product VersionDaily / GIT 
Target VersionFixed in Version3.34 
Summary0004231: JvDBGrid - ignores CanDelete property
DescriptionJvDBGrid.pas, line 1512 and forth
 
procedure TJvDBGrid.KeyDown(var Key: Word; Shift: TShiftState);
"VK_DELETE" case branch
 
what if we set CanDelete to false ?
JvDBGrid will skip this branch and pass VK_DELETE to inherited TDBGrid handler.
And will delete the row.
 
Instead this event should be cleared in CanDelete is False.
 
 
 
I also think there should be the same CanInsert property to disallow row insertion by user. This is done is a number of free 3rdparty components, so there is to be where to borrow code from :-) It would be harder than preventing Delete: at least there is one more way to insert new record by scrolling after end of table.
Steps To ReproduceJust set CanDelete to false, then, focused the grid, press Ctrl+Del - there would be standard VCL's pormpt for deletion, and then row would be deleted.
Additional InformationPersonally i patched it this way (however maybe that is just ugly temporary hack)

        VK_DELETE:
          if CanDelete and not ReadOnly and CanModify and not
            IsDataSetEmpty(DataLink.DataSet) then
          begin
            if DeletePrompt then
            begin
              if SelectedRows.Count > 0 then
                SelectedRows.Delete
              else
                Delete;
            end;
            Exit;
          end
          else Exit; //don't bubble Del into TDbGrid!
TagsNo tags attached.

Activities

obones

2007-10-12 08:46

administrator   ~0013939

Thanks, this is in SVN.
If you manage to workout the CanInsert property, please create a new issue with the changes attached.

Issue History

Date Modified Username Field Change
2007-09-20 12:50 Arioch New Issue
2007-10-12 08:46 obones Status new => resolved
2007-10-12 08:46 obones Fixed in Version => Daily / SVN
2007-10-12 08:46 obones Resolution open => fixed
2007-10-12 08:46 obones Assigned To => obones
2007-10-12 08:46 obones Note Added: 0013939