vbdavie Posted August 26, 2015 Share Posted August 26, 2015 I had a topic on TListView and no replies I am in dire need to have a list shown to the user and to let the user "checkmark" the items they want. THEN I have a button that processes all the items that are checkmarked. How to do this? I know that in the stringgrid, I can click on several items to select "multiple" items, BUT, if the user then accidentally clicks on another item, then it messes up the selections. They are too fragile and the user can mess up the selections without realizing it. So, a checkbox is more intuitive and you can easily see what's checked and what's not checked. I've looked long and hard and I don't see anything for this. Did I miss something cool? Seems to me that a checkbox feature in some sort of list would be a key feature. Since the items are manually generated, I can't use any of the DB controls. Thanks Davie Link to comment Share on other sites More sharing options...
ferna Posted August 27, 2015 Share Posted August 27, 2015 Afaik there's no "classic" way to do that (i'm working with 0.99.50.1189). In my case i've got to use a virtual table (TClientDataSet) with a boolean field that has a getter to avoid the "true" and "false" displayed text when linked with dbgrid. I've got to walk the dataset to obtain the values but i don't have to worry about the checkbox it does its job.You can try "BMUniDBGrid" too http://forums.unigui.com/index.php?/topic/5044-new-bmunidbgrid-with-multiselection-rows-and-popupmenu-vers-098-and-099/ , i'm working with D2007 and i have no time to port it nor try it.Good luck. Link to comment Share on other sites More sharing options...
vbdavie Posted August 27, 2015 Author Share Posted August 27, 2015 I wonder why there is no "classical" way to show a ListView. Seems like it would be a nice/needed controll. WoW. Is there a way to know which ROW of a stringgrid that I may have dbl-clicked on? So, you are saying to use the DBGrid. Now you say you do it in VIRTUAL mode? That would be acceptable if I could load up the data into the "virtual" area by myself. So "virtual" is the way we can use the DB controls without actually accessing a true database? If that's the case, then I'm all gung-ho. I will take a look at your project to see what I can suck out of it. Thanks Davie Link to comment Share on other sites More sharing options...
vbdavie Posted August 27, 2015 Author Share Posted August 27, 2015 Huh, I always used Pervasive SQL or MySQL or MS SQL or DBase. I never used the TClientDataSet I just read about it and it looks freaking EZ to do. I will do that and drop the dumb string grid. Davie Link to comment Share on other sites More sharing options...
FastCards Posted August 28, 2015 Share Posted August 28, 2015 Davie, I used to use StringGrids a lot when programming for Windows. When I moved to UniGUI it became clear that StringGrids are too restrictive in many ways and I read up on and tried ClientDataSets. Haven't looked back, definitely worth a try. Link to comment Share on other sites More sharing options...
ferna Posted August 28, 2015 Share Posted August 28, 2015 yep, its really easy and you don't have to link a "real" database, the annoying part is to walk the dataset to set/get the values but... nothing in life is free except GNU. Link to comment Share on other sites More sharing options...
vbdavie Posted August 28, 2015 Author Share Posted August 28, 2015 Yes, I converted to use the DBGrid and it works PERFECTLY. EXCEPT for one thing that I noticed. I have a boolean field called "Tag". I use it so that the user can CHECKMARK a record. That "sort-of" works. More on that later. When you click on the checkmark it doesn't always change the checkmark status. I will start a new topic on "DBGrid Checkbox not working" and you will see what I'm talking about. I can demonstrate it with the sample demo app. Davie Link to comment Share on other sites More sharing options...
Sherzod Posted August 29, 2015 Share Posted August 29, 2015 Checkbox in a list / NO DB While in the process ... Hi, Checkbox can be added by changing the boundList.tpl, You can check, Try: UniListBox1 -> ClientEvents -> ExtEvents -> add function beforerender: function beforerender(sender, eOpts) { document.doEvt = function(el) { //console.log(el.id); }; sender.boundList.tpl.html = '<ul class="x-list-plain"><tpl for="."><table><tr><td id={[Ext.id()]}><input id={[Ext.id()]} type="checkbox" onclick="doEvt(this)"/></td><td width="100%"><li role="option" unselectable="on" class="x-boundlist-item">{val}</li></td></tr></table></tpl></ul>' } Next, need to consider further "actions"! Best regards. Link to comment Share on other sites More sharing options...
ganzqgy Posted August 29, 2015 Share Posted August 29, 2015 function beforerender(sender, eOpts){ document.doEvt = function(el) {console.log(el.id);}; sender.boundList.tpl.html =' <ul class="x-list-plain"> <tpl for="."> <li role="option" unselectable="on" class="x-boundlist-item"> <input id={[Ext.id()]} type="checkbox" onclick="doEvt(this)"/> {#}.{val} </li> </tpl> </ul> '} Dynamically add or delete, serial number is not normal。 UniListBox1.Items.Add('fdsa'); UniListBox1.Items.Delete(UniListBox1.ItemIndex ); Why? Link to comment Share on other sites More sharing options...
Sherzod Posted August 29, 2015 Share Posted August 29, 2015 Hmm, Yes, you're right, #, [xindex] does not work.. We can do so, but it will affect the status of checkboxes.. after add item: UniSession.AddJS(UniListBox1.JSName + '.boundList.refresh();'); Link to comment Share on other sites More sharing options...
ganzqgy Posted August 29, 2015 Share Posted August 29, 2015 Good! Thank you. Link to comment Share on other sites More sharing options...
arilotta Posted August 4, 2017 Share Posted August 4, 2017 Hi Delphi Developer, I found this "old" thread because I wanted to add checkboxes to unilistbox with multiselect=true. Your solution works, the checkboxes are displayed. But, if inspecting the unilistbox selected property, no row is marked as selected: var I: Integer; begin for I := 0 to CHKIndicazione.Items.Count - 1 do if CHKIndicazione.Selected then showmessage(CHKIndicazione.items) end; What's the problem ? Thanks Andrea Link to comment Share on other sites More sharing options...
arilotta Posted August 21, 2017 Share Posted August 21, 2017 Hi Delphi Developer, is there a way to have the selection on a UniListBox to be made only with the checkboxes ? I would like to have the UniListBox.Selected list to be populated only with the checked items, rather than by the Ctrl+click and Shift+click events. Thanks Andrea Link to comment Share on other sites More sharing options...
Sherzod Posted August 24, 2017 Share Posted August 24, 2017 Hi, Hi Delphi Developer, is there a way to have the selection on a UniListBox to be made only with the checkboxes ? I would like to have the UniListBox.Selected list to be populated only with the checked items, rather than by the Ctrl+click and Shift+click events. Thanks Andrea Well, if follow this approach, you can try this solution: function beforerender(sender, eOpts) { var me = sender, list = sender.boundList; document._chSelect = function(indx) { ajaxRequest(me, "checkSelect", ["indx=" + (indx - 1)]); }; list.tpl.html = '<ul class="x-list-plain"><tpl for="."><table><tr><td id={[Ext.id()]}><input id={[Ext.id()]} type="checkbox" onclick="_chSelect({#})"/></td><td width="100%"><li role="option" unselectable="on" class="x-boundlist-item">{val}</li></td></tr></table></tpl></ul>'; list.addListener('beforeitemclick', function() { return false }); list.addListener('beforecontainerclick', function() { return false }) } procedure TMainForm.UniListBox1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var Indx: Integer; begin if EventName = 'checkSelect' then begin Indx := StrToInt(Params.Values['indx']); (Sender as TUniListBox).Selected[Indx] := not ((Sender as TUniListBox).Selected[Indx]); end; end; ClearSelection: procedure TMainForm.UniButton1Click(Sender: TObject); begin UniListBox1.ClearSelection; UniListBox1.JSInterface.JSCall('boundList.refresh', []); end; Best regards, Link to comment Share on other sites More sharing options...
Sherzod Posted August 24, 2017 Share Posted August 24, 2017 Select programmatically: nth(n) (1 based) procedure TMainForm.UniButton2Click(Sender: TObject); begin UniListBox1.ClearSelection; UniListBox1.Selected[1]:=True; UniListBox1.JSInterface.JSCode(#1'.el.select("input[type=checkbox]:nth(2)").elements[0].checked=true;'); UniListBox1.Selected[4]:=True; UniListBox1.JSInterface.JSCode(#1'.el.select("input[type=checkbox]:nth(5)").elements[0].checked=true;'); end; Link to comment Share on other sites More sharing options...
arilotta Posted August 28, 2017 Share Posted August 28, 2017 Thank you very much Delphi Developer, I developed a simple component based on your code and posted it in the following thread: http://forums.unigui.com/index.php?/topic/9041-new-tunichecklistbox-component/ Andrea Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now