Solved

Removing duplicates and white space between entries

Posted on 2014-10-30
6
118 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
  • 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now