[CLOSED] Projection of getRowsValues?

  1. #1

    [CLOSED] Projection of getRowsValues?

    I have two grids - MyCategoryGrid and MyItemsGrid which display data from two database tables, MyCategory and MyItems. MyCategoryID is the PK in MyCategory and the FK In MyItems.

    I have a function, ShowItems, that gets the selected items from MyCategoryGrid and shows all the associated MyItems in MyItemsGrid. I pass the selection using store.getRowsValues to get an Ext.data.Model, and pass that to a DirectMethod which takes it in as a Dictionary<string, string>[] MySelectedCategories. I then create a List<int> MySelectedCategoryIDList in C#:

    
    ItemsJS = {
      ShowItems: function() {
        var MySelectedCategories = MyCategoryGrid.getRowsValues({selectedOnly: true});
        App.direct.GetItemsForCategory(MySelectedCategories);
      }
    };
    [DirectMethod]
    void GetItemsForCategory(Dictionary<string,string>[] MySelectedCategories)
    {
      List<int> mySelectedCategoryIDList = MySelectedCategoryIDList(MySelectedCategories);
      BindItemsGridForSelectedCategories(mySelectedCategoryIDList);
    }
    
    List<int> MySelectedCategoryIDList(Dictionary<string,string>[] MySelectedCategories) 
    {
      List<int> MySelectedCategoryIDList = new List<int>();
      foreach (Dictionary<string,string> MyCategory in MySelectedCategories)
      {
        MySelectedCategoryIDList.Add(Int32.Parse(MyCategory["MyCategoryID"]));
      }
      return MySelectedCategoryIDList;
    }
    and pass that back to a stored procedure which returns the values for the MyItemsGrid.

    I'd love to push the process of projecting the MyCategoryID column from MyCategoryGrid to a library function; say a

    ItemsJS = {
      ShowItems: function() {
        var mySelectedCategoryIDList = MyCategoryGrid.getRowsValues({selectedOnly: true}).getColumnValues("MyCategoryID");
        BindItemsGridForSelectedCategories(mySelectedCategoryIDList)
      }
    };
    Is there such a function? (I can't find an appropriate method on the Sencha site or in the ext-all.js file).

    Thanks!
    Last edited by Baidaly; Nov 06, 2013 at 12:05 AM. Reason: [CLOSED]
  2. #2
    Hello!

    If I understood your correctly that you want to get just an array with selected IDs, you should use map function: http://docs.sencha.com/extjs/4.1.3/#...ray-method-map

    MyCategoryGrid.getRowsValues({selectedOnly: true}).map(function(item) { return item['MyCategoryID']; })
  3. #3
    Yes, you got the question right ... And I had forgotten about the map function. Thanks!
  4. #4

    IE 8

    So, I switched my JS function over to use the JavaScript array map function, and it worked great on development under Chrome and IE 10.

    When I moved it up to production to test in IE 8, I got an "Object doesn't support this property or method" error.

    This is because IE8 doesn't support the map function.

    Are you folks using it internally? If so, how are you getting it to work?

    [See <http://stackoverflow.com/questions/7350912/is-the-javascript-map-function-supported-in-ie8>]

    Thanks!

    PTR
  5. #5
    Please use Ext.Array.map function
    http://docs-origin.sencha.com/extjs/...ray-method-map
  6. #6
    Thanks, Vladimir! I was confused by the example above:

    MyCategoryGrid.getRowsValues({selectedOnly: true}).map(function(item) { return item['MyCategoryID']; });
    Obviously this is just the basic JavaScript map function. It looks like it should be done this way with Ext.Array.map:

    Ext.Array.map(MyCategoryGrid.getRowsValues({selectedOnly: true}), function(item) { return item['MyCategoryID']; });
    This is working fine in my development environment, so I assume I have the syntax right.

    Thanks!
    Last edited by ptrourke; Nov 11, 2013 at 7:19 PM.
  7. #7
    Just IE8 doesn't have the map method in its arsenal for arrays.

Similar Threads

  1. [CLOSED] #{gvTransactionList}.getRowsValues() in code behind
    By canusr1 in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 23, 2013, 4:58 AM
  2. GridPanel getRowsValues() bug
    By kakagu in forum 1.x Help
    Replies: 4
    Last Post: Apr 17, 2012, 1:22 AM
  3. GridPanel and getRowsValues()
    By Tallmaris in forum 1.x Help
    Replies: 2
    Last Post: Jul 01, 2011, 8:45 AM
  4. getRowsValues but in Code behind
    By EzaBlade in forum 1.x Help
    Replies: 0
    Last Post: Nov 16, 2009, 7:29 AM
  5. grid getRowsValues
    By [WP]joju in forum 1.x Help
    Replies: 4
    Last Post: Oct 06, 2009, 8:13 AM

Tags for this Thread

Posting Permissions