indexOf - 2.0 error... Help! I am desperate?!?

  1. #1

    indexOf - 2.0 error... Help! I am desperate?!?

    I have a store - am performing some summary calculations - for the purposes of this calculation - I need to remove duplicate records with same "PackageID" - I found the below - which apparently works in 1.0 but in 2.0 - I get an error on "indexOf" - I am desperate and need to get this in place ASAP... Any help would be GREATLY appreciated and save my day!

       var uniqueIds = store.collect("PackageID");
                store.filterBy(function (r) {
                    var id = r.data.PackageID;
                    if (uniqueIds.indexOf(id) !== -1) {
                        uniqueIds.remove(id);
                        return true;
                    } else {
                        return false;
                    }
                });
  2. #2
    ExtJS 4.x doesn't inject own methods to standard prototypes anymore, use Ext.Array.indexOf method
    http://docs.sencha.com/ext-js/4-1/#!...method-indexOf
  3. #3
    OK - That seems to work - I wanted to perform a summary calculation on unique packageIDs only - but still display all inthe grid - so tried the below with the clearFilter at the end - if I take the clearFilter out - the calculation works - but if I leave it in - the calculation picks up all values...


    var calculate = function (store, field, field2) {
    
                var sum = 0, summaryRecord;
                store.each(function (r) {
                    //var dup = unique('PackageID', r.get('PackageID'));
                    if (r.isSummary) {
                        summaryRecord = r; return;
                    }
    
                    var uniqueIds = store.collect("PackageID");
                    store.filterBy(function (r) {
                        var id = r.data.PackageID;
                        if (Ext.Array.indexOf(id) !== -1) {
                            uniqueIds.remove(id);
                            return true;
                        } else {
                            return false;
                        }
                    });
    
                    sum += r.get(field) * r.get(field2);
                });
                App.storeTarget.clearFilter();

Similar Threads

  1. Replies: 1
    Last Post: Jan 12, 2013, 4:50 AM
  2. [CLOSED] Store.indexOf: error
    By supera in forum 2.x Legacy Premium Help
    Replies: 16
    Last Post: Oct 04, 2012, 12:18 PM
  3. [CLOSED] MultiSelect indexof listitem always null
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Jul 13, 2012, 7:53 AM
  4. Response after ajaxevents??? Desperate!!
    By Tbaseflug in forum 1.x Help
    Replies: 3
    Last Post: Oct 29, 2010, 7:17 PM
  5. Desperate Help Needed for V0.7
    By EzaBlade in forum 1.x Help
    Replies: 1
    Last Post: Jul 07, 2009, 6:06 PM

Posting Permissions