Jump to content

how to span a rows base on a Column Data?


molla2005b

Recommended Posts

Hi,

 

Can you try to use this approach?, but of course with some "limitations" I think...

 

For example for "column=0":

 

1. UniDBGrid -> ClienEvent -> UniEvents -> function beforeInit:

function beforeInit(sender, config)
{
    config.updateRowSpan = function() {
        var columns = sender.getColumns(),
            view = sender.getView(),
            store = sender.getStore(),
            rowCount = store.getCount(),
            
            column = columns[0],
            dataIndex = column.dataIndex,
            
            spanCell = null,
            spanCount = null;
            spanValue = null;
        
        for (var row = 0; row < rowCount; ++row) {
            var cell = view.getCellByPosition({ row: row, column: 0 }).dom,
                record = store.getAt(row),
                value = record.get(dataIndex);
            
            if (spanValue != value) {
                if (spanCell !== null) {
                    spanCell.rowSpan = spanCount;
                }
                
                Ext.fly(cell).setStyle('display', '');
                spanCell = cell;
                spanCount = 1;
                spanValue = value;
            } else {
                spanCount++;
                Ext.fly(cell).setStyle('display', 'none');
            }
        }
        
        if (spanCell !== null) {
            spanCell.rowSpan = spanCount;
        }
    };
}

2. UniDBGrid -> ClienEvent -> UniEvents -> function afterCreate:

function afterCreate(sender)
{
   sender.getView().on('refresh', sender.updateRowSpan, sender);
}

Result:

 

post-906-0-92357500-1488353668_thumb.png

 

http://jsfiddle.net/wQSQM/3/

 

Best regards.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

Can you try to use this approach?, but of course with some "limitations" I think...

 

For example for "column=0":

 

1. UniDBGrid -> ClienEvent -> UniEvents -> function beforeInit:

function beforeInit(sender, config)
{
    config.updateRowSpan = function() {
        var columns = sender.getColumns(),
            view = sender.getView(),
            store = sender.getStore(),
            rowCount = store.getCount(),
            
            column = columns[0],
            dataIndex = column.dataIndex,
            
            spanCell = null,
            spanCount = null;
            spanValue = null;
        
        for (var row = 0; row < rowCount; ++row) {
            var cell = view.getCellByPosition({ row: row, column: 0 }).dom,
                record = store.getAt(row),
                value = record.get(dataIndex);
            
            if (spanValue != value) {
                if (spanCell !== null) {
                    spanCell.rowSpan = spanCount;
                }
                
                Ext.fly(cell).setStyle('display', '');
                spanCell = cell;
                spanCount = 1;
                spanValue = value;
            } else {
                spanCount++;
                Ext.fly(cell).setStyle('display', 'none');
            }
        }
        
        if (spanCell !== null) {
            spanCell.rowSpan = spanCount;
        }
    };
}

2. UniDBGrid -> ClienEvent -> UniEvents -> function afterCreate:

function afterCreate(sender)
{
   sender.getView().on('refresh', sender.updateRowSpan, sender);
}

Result:

 

attachicon.gifCellsMerge.png

 

http://jsfiddle.net/wQSQM/3/

 

Best regards.

 

 

 

 

Hi,Delphi Developer

     

     if change dataset,for example:append record or delete record ,the unidbgrid is wrong!

    There are more perfect way?

 

   thank you

Link to comment
Share on other sites

 

Hi,

 

 

How do you do it?!

 

Can you try to use this code after modification?:

UniSession.AddJS(UniDBGrid1.JSName + '.view.refresh();');

 

Hi,

I try it,but unidbgrid not refresh,must repaint ??

 

md01.FDQ_jiageZB.edit;
 
  md01.FDQ_jiageZB.FieldByName('grp_par_parname').AsString := trim(UniComboBox1.Text);
  md01.FDQ_jiageZB.FieldByName('grp_parname').AsString := trim(UniComboBox2.Text) ;
  md01.FDQ_jiageZB.FieldByName('grp_name').AsString := trim(Uniedit1.Text);
  md01.FDQ_jiageZB.FieldByName('grp_price01').AsFloat := strtofloat(Uniedit2.Text)  ;
  md01.FDQ_jiageZB.FieldByName('grp_price02').AsFloat := strtofloat(Uniedit3.Text)  ;
  md01.FDQ_jiageZB.FieldByName('grp_price03').AsFloat := strtofloat(Uniedit4.Text)  ;
  md01.FDQ_jiageZB.post ;
  //UniSession.AddJS(UniDBGrid2.JSName + '.view.beforeInit();');
 //UniSession.AddJS(UniDBGrid2.JSName + '.view.repaint();');
  UniSession.AddJS(UniDBGrid2.JSName + '.view.refresh();');
Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...
  • 6 months later...
On 3/7/2021 at 9:19 PM, Sherzod said:

Hello,

Please specify which edition of UniGUI are you using?

Hello,

It doesn't work at the latest complete Professional edition 1.90.0.1551

Could you please suggest any solutions to Merge Cells in column for the same value?

Kind Regards,

J

 

Link to comment
Share on other sites

  • 5 months later...
On 9/24/2021 at 12:12 AM, JamesP said:

It doesn't work at the latest complete Professional edition 1.90.0.1551

Could you please suggest any solutions to Merge Cells in column for the same value?

 

On 3/21/2022 at 3:32 AM, loQsoft said:

There is a way to Merge Cells for the same value ?

Version : 1.90.0.1551

Hello,

You can try with these changes:

function beforeInit(sender, config)
{
    config.updateRowSpan = function() {
        var columns = sender.getColumns(),
            view = sender.getView(),
            store = sender.getStore(),
            rowCount = store.getCount(),
            
            colIndx = 1; // second column for example
            column = columns[colIndx],
            dataIndex = column.dataIndex,
            
            spanCell = null,
            spanCount = null;
            spanValue = null;
        
        for (var row = 0; row < rowCount; ++row) {
            var cell = view.getCellByPosition({ row: row, column: colIndx }).dom,
                record = store.getAt(row),
                value = record.get(dataIndex);
            
            if (spanValue != value) {
                if (spanCell !== null) {
                    spanCell.rowSpan = spanCount;
                }
                
                //Ext.fly(cell).setStyle('display', '');
                Ext.fly(cell).query('.x-grid-cell-inner')[0].style.display='';
                spanCell = cell;
                spanCount = 1;
                spanValue = value;
            } else {
                spanCount++;
                //Ext.fly(cell).setStyle('display', 'none');
                Ext.fly(cell).query('.x-grid-cell-inner')[0].style.display='none';
            }
        }
        
        if (spanCell !== null) {
            spanCell.rowSpan = spanCount;
        }
    };
}

 

function afterCreate(sender)
{
    sender.getView().on('refresh', sender.updateRowSpan, sender);
}

 

  • Thanks 1
Link to comment
Share on other sites

  • 3 weeks later...

Hello @Sherzod

Thank you for your contacts regarding uniGui.

Your suggestions are 99% successful in my targetGUi, a plan for answering projects.

I use it.

Delphi 10.2
uniGui 1.90.0.1550

However, this does not work for your suggestion.

Could it be from the UniGUI version?

Best regards,

  • Like 1
Link to comment
Share on other sites

19 minutes ago, loQsoft said:

and Thank you very much, it is my fault.

Okay, np.

19 minutes ago, loQsoft said:

and i wonder how i can merge colum 1, colum 3 and colum 4 in a same dbgrid ?

Do you mean individually or exactly horizontally?

Link to comment
Share on other sites

config.updateRowSpan = function() {
        var columns = sender.getColumns(),
            view = sender.getView(),
            store = sender.getStore(),
            rowCount = store.getCount(),
            
            colIndx = 1; // second column for example--> IT IS SECOND COLUMN
            column = columns[colIndx],
            dataIndex = column.dataIndex,

 

if there are 3 coulmn to merge ? what can i do ?

I mean

ColIndx = 1;

for one column and column number second

 

i try to learn; vertically 

 

Best Regards,

 

 

 

 

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...