Jump to content


Photo

tunidbgrid color combo

grid color combo

  • Please log in to reply
11 replies to this topic

#1 zanona

zanona

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 11 September 2017 - 05:15 PM

Is there any way to include a tunidbgrid color combo?
 
See image below
 
Thanks
 
Zanona

Attached Files


  • 0

#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3029 posts

Posted 13 September 2017 - 04:05 PM

Hi,

 

In process... :)

If I can finish, I'll let you know

 

Attached File  colorCombo.png   10.56KB   1 downloads

 

Best regards,


  • 0

#3 zanona

zanona

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 13 September 2017 - 05:36 PM

Perfect! When will you release? If you want I can test for you :)


  • 0

#4 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3029 posts

Posted 13 September 2017 - 05:40 PM

Ok, maybe tomorrow, I will share my solution.
  • 0

#5 zanona

zanona

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 13 September 2017 - 06:06 PM

Show  :D


  • 0

#6 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3029 posts

Posted 14 September 2017 - 06:40 PM

Hi,

 

"Solution", you can test it:

 

1. MainForm -> Script:

 

Spoiler

 

2. UniComboBox1 in HiddenPanel,

UniComboBox1 -> ClientEvents -> UniEvents, ExtEvents ->

 

beforeInit:

function beforeInit(sender, config) 
{
    config.listConfig = {
        tpl: new Ext.XTemplate(
            '<tpl for="."><div class="x-boundlist-item"><span style="background: {[this.getHex(values.val)]}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;{val}</div></tpl>', {
                disableFormats: true,
                getHex: function(values) {
                    return colors[values.toUpperCase()] ?
                        colors[values.toUpperCase()] :
                        'color not found';
                }
            }
        )

    };
}

change:

function change(sender, newValue, oldValue, eOpts) 
{
    var element = sender;
    var inputEl = element.inputCell.child('input');
    var data = element.getStore().findRecord(element.valueField, newValue);

    if (data) {
        inputEl.applyStyles('padding-left:42px');
        var parent = inputEl.parent(),
            spanDomEle = parent.child('span');

        if (!spanDomEle) {
            Ext.DomHelper.insertFirst(parent, {
                tag: 'span',
                html: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
            });
            var newSpanDomEle = parent.child('span');
            newSpanDomEle.applyStyles('background-color: ' + getHexa(data.get(element.displayField)) + ';float: left; position: absolute; top: 0.9px; margin: 3px 2px 2px 4px; width: 33px; height: 15px;');
        } else {
            spanDomEle.applyStyles('background-color:' + getHexa(data.get(element.displayField)));
        }
    }
}

focus:

function focus(sender, e, eOpts) 
{
    var parent = sender.inputCell.child('input').parent(),
        spanDomEle = parent.child('span');

    if (spanDomEle) {
        spanDomEle.applyStyles('background-color:' + getHexa(sender.value));
    }
}

3. UniDBGrid1 -> Columns -> "comboColor" column:

Editor -> UniComboBox1

 

4. UniDBGrid1 -> ClientEvents -> ExtEvents -> function reconfigure:

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    // Indx=8 yourColumnIndx
    columns[8].renderer = function(v) {
        return '<span style="float: left; width: 33px; height: 15px; background: ' + getHexa(v) + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;' + v;
    }
}

Try...

Best regards,


  • 0

#7 zanona

zanona

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 15 September 2017 - 11:46 AM

I did as suggested! But the last column went blank and the column "background color" did not load the combo!
 
NOTE: I'm creating the screen via frame. Does this make a difference?

  • 0

#8 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3029 posts

Posted 15 September 2017 - 12:09 PM

Hi,

Can you make a simple testcase?

Best regards,
  • 0

#9 zanona

zanona

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 15 September 2017 - 01:03 PM

The column disappears, see image below! I took a test now on a form!

coluna%20some.png


  • 0

#10 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3029 posts

Posted 15 September 2017 - 01:19 PM

If you have a problem with this solution, please make a test case, we will analyze


  • 0

#11 zanona

zanona

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 16 September 2017 - 12:26 AM

Sample with error!

 

http://187.45.244.12...os/Project1.zip


  • 0

#12 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3029 posts

Posted 18 September 2017 - 04:54 AM

Hi,

 

I'm sorry,

 

First of all, I forgot about "UniComboBox -> Items":

 

Spoiler

 

Secondly:

 

In your example, the "index" is incorrect:

 

1. TVCLDBColumns[0] -> Editor -> UniComboBox1 - incorrect

2. TVCLDBColumns[1] -> Editor -> UniComboBox1 - correct

 

Reconfigure:

 

columns[0].renderer - incorrect

columns[1].renderer - correct

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
    // Indx=8 yourColumnIndx
    columns[1].renderer = function(v) {
        return '<span style="float: left; width: 33px; height: 15px; background: ' + getHexa(v) + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;' + v;
    }
}

Best regards,


  • 0





Also tagged with one or more of these keywords: grid, color, combo

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users