Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Feb 2010
    Posts
    34
    Vote Rating
    0
    umit is on a distinguished road

      0  

    Default store with distinct option

    store with distinct option


    Hallo!
    I wrote a function, that you can use for distinct Element filtering.
    The purpose is if you get resultsets with joins and have more entries, and you want to show the entries in more than one combobox you will get double entries, if you use the same store.
    You may want to filter this "double entries".
    Of corse you could make 2 requests to the server, but why bother the server with requests, if the client can do it(you may have performace issues on the server).

    If your store looks like this:
    Name
    Anton
    Toni
    Toni

    you will get this:
    Name
    Anton
    Toni

    Here the code:
    function getDistinctStore(store,distinctKey){//info: store is a json store
    var newstore=new Ext.data.ArrayStore();
    var record;
    store.data.each(function(rec){
    if(record==null){
    newstore.add(rec);
    record=rec;
    }
    else
    if(record.get(distinctKey)!=rec.get(distinctKey)){
    newstore.add(rec);
    record=rec;
    }
    });
    return newstore;
    }
    It would be nice if Ext would have this as standard.
    greets umit

  2. #2
    Sencha User
    Join Date
    Feb 2012
    Posts
    10
    Vote Rating
    0
    dhilchrist is on a distinguished road

      0  

    Default Distinct rows from an Ext.data.XmlStore

    Distinct rows from an Ext.data.XmlStore


    Distinct rows from an Ext.data.XmlStore?? (Extjs 3.3.0 lib)

    how can I retrieve distinct rows from an XmlStore,

    Data Set
    Job operation RunId Status
    a launch 123 Pass
    a lunch 123 Pass
    a hold 124 Wait
    a hold 124 wait

    Result set,
    I wanted to display only 2 rows based on RunId

    a launch 123 Pass
    a hold 124 wait

  3. #3
    Sencha User
    Join Date
    Feb 2010
    Posts
    34
    Vote Rating
    0
    umit is on a distinguished road

      0  

    Default


    Hi,
    use the filter function from the store,
    i wrote this, when i was new to extjs and the implementation of mine has some kinda problems e.g. the store has to be sorted.


    For your solution the filter function should do it, based on the criteria to filter(if you have the runid as seperate field in the store).
    so something like:

    Code:
    var addedRunIds=[];
    myXmlStore.filterBy(function(rec){
    if(addedRundIds.indexOf(rec.get("runid")==-1){//does not contain it
    addedRunIds.add(rec.get("runid")); return true;
    } return false;
    }
    You can also make a new store and add to to the store instead of filtering it.
    greets
    Last edited by umit; 9 Jul 2012 at 11:22 PM. Reason: -1 instead of 1

  4. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    10
    Vote Rating
    0
    dhilchrist is on a distinguished road

      0  

    Default xmlstore filterby, extjs 3.3.0

    xmlstore filterby, extjs 3.3.0


    thanks umit,
    i tried like this but getting errors..expected string, identifier, number!!
    store.load({
    callback : function() {
    var addedRunIds=new Array();
    for (var i = 0; i < store.getCount() - 1; i++) {
    record = store.getAt(i);
    store.filterBy({
    function(record){
    if(addedRunIds.indexOf(record.get("TESJobRunID")==1){//does not contain it
    addedRunIds.add(record.get("TESJobRunID"));
    return true;
    }
    return false;
    }
    });
    }
    }
    });

  5. #5
    Sencha User
    Join Date
    Feb 2010
    Posts
    34
    Vote Rating
    0
    umit is on a distinguished road

      0  

    Default


    Hi,
    You have 2 variables with the name record, it is difficult to tell which one is the one you use, you should take a different name like record2, otherwise you have to work with this.record, but that's fuzzy.

    And when you use indexOf it return -1 when it cant find the record, not 1, sry i wrote 1 ...

    try this
    Code:
    store.load({
    	callback : function() {
    		var addedRunIds=[];
    		store.filterBy(function(rec){
    			if(addedRunIds.indexOf(record.get("TESJobRunID")==-1){//does not contain it
    				//so add it and show it
    				addedRunIds.push(rec.get("TESJobRunID"));
    				return true;
    			}
    			return false;
    		});
    	} 
    });
    What is the content of TESJobRunID ?

    Is it:
    a launch 123 Pass
    a lunch 123 Pass
    a hold 124 Wait
    a hold 124 wait

    or
    123
    123
    124
    124

    if it is the 1. you have to split it to get the id.

  6. #6
    Sencha User
    Join Date
    Feb 2012
    Posts
    10
    Vote Rating
    0
    dhilchrist is on a distinguished road

      0  

    Default


    the contents of TESJobRunId are
    123
    123
    124
    124

  7. #7
    Sencha User
    Join Date
    Feb 2012
    Posts
    10
    Vote Rating
    0
    dhilchrist is on a distinguished road

      0  

    Default


    do I need to declare the function variable record/rec, id of function(record, id)?
    if not I can use this rec.get("TESJobRunID") in the function right ?

  8. #8
    Sencha User
    Join Date
    Feb 2012
    Posts
    10
    Vote Rating
    0
    dhilchrist is on a distinguished road

      0  

    Default


    if I use your code inside the store.load then it is filtering only the first page of the grid and also i tried without store.load but it is not filtering.
    ----------------------------
    var store = new Ext.data.XmlStore({
    autoDestroy: true,
    storeId: 'myStore',
    proxy: proxy,
    root : "standard",
    record: 'standardData',
    idPath: 'rowId',
    totalProperty: '@totalCount',
    autoLoad: false,
    paramNames: {
    start: 'startRow',
    limit: 'recordSize'
    },
    fields: fieldObjectList
    });




    store.load({
    callback : function() {
    var addedRunIds=[];
    store.filterBy(function(rec){
    if(addedRunIds.indexOf(rec.get("TESJobRunID"))==-1){//does not contain it
    //so add it and show it
    addedRunIds.push(rec.get("TESJobRunID"));
    return true;
    }
    return false;
    });
    }
    });
    /* create the grid */
    var grid = new Ext.grid.GridPanel({
    store : store,
    columns : displayList,
    renderTo : '#divName#',
    width : "100%",
    autoHeight : true,
    plugins: [filterRow],
    stripeRows: true,
    layout : 'fit',
    viewConfig : {
    forceFit : true
    },
    bbar : [new Ext.PagingToolbar({
    store : store,
    displayInfo : true,
    pageSize : 10,
    params:{
    startRow: 0,
    recordSize: 10
    }
    })]
    });
    -----------------------------

  9. #9
    Sencha User
    Join Date
    Feb 2010
    Posts
    34
    Vote Rating
    0
    umit is on a distinguished road

      0  

    Default


    Hi,

    you can use it by record.get("xyz") you don't need more variables.

    What do you mean by: it's filtering the first page? does it have many pages? do you load only a part of the whole runids by the server?

    You have to load and filter afterwards. So everytime you load, you have to filter. You can use an event, so that it autofilters when you load. The syntax would be:
    Code:
    store.on("load",function(){
    //your filter function
    });
    But be careful with the filter, whenever you iterate it, you will only get the elements, that are shown. So when you use the store for something else too, use another store with the same structure.

  10. #10
    Sencha User
    Join Date
    Feb 2012
    Posts
    10
    Vote Rating
    0
    dhilchrist is on a distinguished road

      0  

    Default


    thanks umit, it works!!!
    yes i have around 1000 records and i am using pagination too, the issue i m facing now is records numbers shows in the pagination, it is showing the actual records# from store not the filtered one.

Similar Threads

  1. count distinct for a particular column
    By emmas in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 23 Aug 2010, 1:26 PM
  2. Editable Grid with All ComboBoxes, and Distinct values?
    By jwong in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 9 Dec 2009, 3:52 AM
  3. How to specify jsonData as option in store.load()?
    By dbassett74 in forum Ext 3.x: Help & Discussion
    Replies: 9
    Last Post: 16 Jul 2009, 5:34 PM
  4. Editable Grid with All ComboBoxes, and Distinct values?
    By jwong in forum Ext GWT: Help & Discussion (1.x)
    Replies: 4
    Last Post: 19 Jun 2008, 2:16 PM
  5. how to distinct editorGrid's cellclick from celldblclick
    By lixiaoxu85 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 28 Apr 2008, 7:13 PM

Thread Participants: 1

Tags for this Thread