Solved

Removing duplicates and white space between entries

Posted on 2014-10-30
6
126 Views
Last Modified: 2014-12-03
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
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 40413082
What UI grid do you use and can you please show some lines around the location where the upper productRenderer function is called?
0
 

Author Comment

by:royjayd
ID: 40413108
sure, ext-js.
My grid column is defined as

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

Thanks.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 40413945
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/
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 63

Expert Comment

by:Zvonko
ID: 40415254
Which version of ExtJs do you use in that application?
0
 

Author Comment

by:royjayd
ID: 40416632
4.2
I have found a way around it which solves my requirment.
thanks.
Any help with my next question will be appreciated.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28548773.html
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 40417138
"I have found a way around it which solves my requirment"
Can you tell me more?

I ask because you let this question open and open a new question using the hint from above: "Better idea is to create a new Store from existing ExtJs Store "

So either assign the points from here to the proposal http://www.experts-exchange.com/Q_28547572.html#a40413945 or explain what your solution here was or let this question be closed by EE Moderators.

Thanks,
Zvonko
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question