Jump to content

How to change background color of odd and even rows in ListBox


Mirco

Recommended Posts

18 hours ago, Mirco said:

i need to change the background color of the rows of a listbox to make them have 2 different colors for the odd and even rows.
It's possible?

Hello,

Try this approach:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniListBox1.JSInterface do
    JSConfigObject('listConfig', 'tpl', [
      JSStatement('new Ext.XTemplate(''<tpl for=".">'',' +
        ' ''<li role="option" unselectable="on" class="x-boundlist-item {[xindex % 2 === 0 ? "x-grid-item-alt" : ""]}">'', '+
        ' ''{val}</li></tpl>'')'
      )]
    );
end;

 

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...