CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Highlight selected item

by markus_ja » 12 Jan 2016 14:27

Hello,

the panellist looks pretty cool.
Is it possible to highlight an item, to show the user what item is currently selected? I would like to use it as drawer menu.
markus_ja
 
Posts: 15
Joined: 10 Jan 2016 10:58

by assapan » 12 Jan 2016 15:30

Hi,
you can use the ItemCss or the icon to emulate a selection
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by markus_ja » 13 Jan 2016 09:01

Hello,

is there a function to add / remove a css attribute?
The ItemCss contains already a css attribute ItemCss := 'panellist-nav-item-li', so I need some function to add / remove a particular string.
I know I can write my own function, but just woundering if you have already a published functionality for that purpose.

Thanks,
markus_ja
 
Posts: 15
Joined: 10 Jan 2016 10:58

by assapan » 13 Jan 2016 09:12

What i have done
Code: Select all
function SetStyleCGControl(ApplyStyle: Boolean; var css: String; Stylecss: string): Boolean;
var
  I: Integer;
  tempcss: string;
begin
  tempcss := css;
  I := Pos(Stylecss, tempcss);

  // in case Stylecss is already in css
  if (I > 0) and (ApplyStyle) then
  begin
    Result := False;
  end
  else
  begin
    if I > 0 then
      Delete(tempcss, I, Length(StyleCss));

    if ApplyStyle then
      tempcss := tempcss + ' ' + Stylecss;
    css := tempcss;
    Result:=True;
  end;
end;


plus a panel list helper
Code: Select all
{ TJqPanelListHelper }

procedure TJqPanelListHelper.SetSelection(Item: TIWCGPanelListItem; Selected: Boolean);
begin
  if SelectIt(Item, Selected) then
    Self.AjaxReRender;
end;

function TJqPanelListHelper.SelectIt(it: TIWCGPanelListItem; Selected: Boolean): Boolean;
var
  TempCss: string;
begin
  result := False;
  if Assigned(it) then
  begin
    TempCss := it.ItemCss;
    if SetStyleCGControl(Selected, TempCss, 'ui-state-highlight') then
    begin
      it.ItemCss := TempCss;
      result := True;
    end;
  end;
end;
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by Jorge Sousa » 13 Jan 2016 16:15

Thanks assapan :=)

setting ItemCss to 'ui-state-highlight' would be good option, but that's only an example.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by assapan » 13 Jan 2016 16:19

hi Jorge , these procedures set or unset 'ui-state-highlight' which is important when changing selected item ;)
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by Jorge Sousa » 13 Jan 2016 16:29

Hello Assapan

You don't need the AjaxReRender part, because you're only changing ItemCss which is already ajax ready.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by assapan » 13 Jan 2016 16:41

Jorge Sousa wrote:Hello Assapan

You don't need the AjaxReRender part, because you're only changing ItemCss which is already ajax ready.


Oh thanks i didn't notice that :oops:
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by Jorge Sousa » 14 Jan 2016 10:36

Hello

AjaxReRender is a good thing, but must be called when the ajax response is not being handled or is handled but the plugin doesn't respond (it's the case of some property value changes, like changing the width columns of the grid).

AjaxReRender, adds or replaces (if the component(s) is (are) already there in the page), all the html, script and css needed, it always take more traffic and time, depending on the complexity of the control, or number of controls envolved.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58


Return to CGPanelList

Who is online

Users browsing this forum: No registered users and 3 guests

Contact Us.