Solved

Removing duplicates and white space between entries

Posted on 2014-10-30
6
123 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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. …
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

786 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