Link to home
Start Free TrialLog in
Avatar of Jay Roy
Jay RoyFlag for United States of America

asked on

Removing duplicates and white space between entries

hi experts

I have a Product name column on my UI grid which has data like this


CRBR
CRBR
CRBR
CRBR
CRBR
TESTRAMP
TESTRAMP
TESTRAMP
TESTRAMP
TESTRAMP
OLIVERP
OLIVERP
OLIVERP
OLIVERP

My requirment is to remove duplicates and remove the white space between each product
Currently i have productRenderer on this column

var  productPlaceHolder = {};
function productRenderer(value, meta) {    
    if( !productPlaceHolder[value] ) {  
        productPlaceHolder[value] = true;        
        return value;
    }
    else {
        return  ''; //removes duplicates
    }
}

After i apply the renderer, it displays like this
CRBR




TESTRAMP




OLIVERP




But my requirment is to display like this
CRBR
TESTRAMP
OLIVERP

Any idea how i can remove the white spaces?

Thanks
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

What UI grid do you use and can you please show some lines around the location where the upper productRenderer function is called?
Avatar of Jay Roy

ASKER

sure, ext-js.
My grid column is defined as

    var columns = [
              {
            id: 'productId',
            dataIndex: 'productId',
            text: 'Product Id',
            width: 300,
            renderer:productRenderer
              },
]

Thanks.
The renderer prepares the records for display but record by record and one by one where you cannot suppress next record or previous record (of course you technically could but it is bad idea).
Better idea is to create a new Store from existing ExtJs Store with the groupField property set to field name to group to distinct rows.
Look at this and look for groupField and collapsable: false
http://blogs.walkingtree.in/2013/11/09/what-can-i-do-with-a-gridpanel-in-extjs/
Which version of ExtJs do you use in that application?
Avatar of Jay Roy

ASKER

4.2
I have found a way around it which solves my requirment.
thanks.
Any help with my next question will be appreciated.
https://www.experts-exchange.com/questions/28548773/ext-js-4-2-creating-multiple-store-instance-in-controller.html
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial