Get a cell values ​​of all records

  1. #1

    Get a cell values ​​of all records

    I hope you can lean on the following:


    I'm trying to get the value of each cell in a column all records showing a GridPanel , I hope I have explained , however 'll upload a picture to show what I want , and this can save it as a string.

    This is my code of left grid:

    var gpMappingConsumable = x.GridPanel()       
           .ID("gpMappingConsumable")
           .Title("Consumibles")
           .Margins("0 0 0 2.5")              
           .SortableColumns(false)
           .Flex(1)       
           .Height(350)
           .SelectionModel
           (
                x.RowSelectionModel()
                .Mode(SelectionMode.Multi)
            )
           .Store
           (
               stMappingConsumable
           )
           .ColumnModel
           (
               x.Column()
               .Text("idEquipo")         
               .DataIndex("_idequipment")
               .Hidden(true),    
            
               x.Column()
               .Text("id")         
               .DataIndex("_idconsumable")
               .Hidden(true),
    
    
               x.Column()
               .Text("No. parte")
               .DataIndex("noPart"),
    
    
               x.Column()
               .Text("Consumible")
               .Width(300)
               .DataIndex("description")
           )
           .View
            (
                x.GridView()
                .LoadMask(true)
            )
            .BottomBar
            (
                x.PagingToolbar()
            )
            .Plugins
            (
                x.FilterHeader()
            );


    this is a image of what I requiered:

    Click image for larger version. 

Name:	one.jpg 
Views:	80 
Size:	78.4 KB 
ID:	24529



    if they need more data so they can help me, tell me , I'm new here
  2. #2
    Hello @Charles! Welcome to Ext.NET forums!!!

    I hope I get your needs.

    Take this example as base: Simple array grid.

    On this example, you can get all "Company" entries with this JavaScript command:

    var itemList = App.GridPanel1.store.data.items;
    for (var i in itemList) {
        console.log(itemList[i].data.company);
    }
    Hope this helps!

    p.s.: you may want to test it yourself on the example, and you might want to open it directly, open developer console and run the above JavaScript code to see the result on your browser. if so, the direct link for the example would be: https://examples2.ext.net/Examples/G...ayGrid/Simple/
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hi @fabricio,

    thanks for your help , I tried and it throws null , I'll show you my code as you like, another question , that way I can bring the total rows of records? I try Row.Count and getRows.Count and it does not work



    This is the code , my idea is to get a string with all records and send it as a parameter to the controller and then send to deserialize record by record into the storeprocedure that will make transactions

                          x.Button()
                          .AnchorHorizontal("40%")
                          .Width(70)
                          .Height(50)
                          .Icon(Icon.ForwardBlue)
                          .PaddingSpec("18 20 16 23")
                          .Hidden((Site.Controllers.Helpers.SessionManager.User._idprofile == 2) ? true : false)
                          .DirectEvents(de =>
                          {
                              de.Click.Url = Url.Action("AllInsertMapConsumable", "CRUD");
                              de.Click.ExtraParams.Add                              
                              (new Parameter
                              {                              
                                  Name = "idEquipo",
                                  Value = "(App.gpMappingConsumable.hasSelection()) ? App.gpMappingConsumable.selModel.getSelection()[0].raw._idequipment : 0",
                                  Mode = ParameterMode.Raw
                              });
                              
                              var itemList = App.gpMappingConsumable.store.data.items;    // this part throws me null
                              foreach(var i in itemList){
                                  de.Click.ExtraParams.Add
                                  (new Parameter
                                  {
                                      Name = "idCon",                                  
                                      Value = "itemList[i].data._idconsumable",
                                      Mode = ParameterMode.Raw                               
                                  });
                              }                
                              de.Click.EventMask.ShowMask = true;
                          }
  4. #4
    Hello Charles!

    Seems you got all mixed up, but let's see if we can help on that. Actually, did Intellisense let you do that without complaining? :)

    The code I provided you was JavaScript code, so it is not supposed to work on a c# code (unless wrapped as a string to be parsed when back to client-side).

    In fact, you done well at line 25. There you are encaspulating JavaScript code. But the outer loop is on server-side, C#, that won't mix up well.

    You can instead remove the loop away and draw a function to gather the values you want.

    That said, take out lines 19, 20 and 28 from your code, and line 25 becomes just:
    Value = "getSelectedValues",
    And then move out of Razor syntax, get to a part of your page where you write JavaScript and program your getSelectedValues() based on the code snippet I provided first.

    var getSelectedValues = function() {
        var itemList = App.gpMappingConsumable.store.data.items;
        var consumableIdList = [];
        for (var i in itemList) {
            consumableIdList[consumableIdList.length] = itemList[i].data._idconsumable;
        }
        return consumableIdList;
    }
    I didn't test this code snippet, but I am pretty confident it will fill your idCon parameter with the list of IDs as you want. Next step then would be, on code behind, "deserialize" the string received to the list of IDs. You can step thru the event with debugger and see how the parameter looks like and parse it to your needs.

    If these sparse instructions are still not enough to help you, provide a full working test case. That is, a sample with the full view (not partial view, without need of extra stuff like @layout) and a controller (you can just stub out a simple model inside the controller itself to keep it simple).

    The simplest the sample you can come up with, the easiest for us to focus on the problem -- or be able to run the test case at all -- and provide you with better feedback! :)

    Anyway, hope this so far was helpful!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Update Gridpanel Cell Values of selected Row
    By d3graph in forum 2.x Help
    Replies: 1
    Last Post: Nov 01, 2013, 12:32 AM
  2. [CLOSED] Gridpanel Cell values right padding
    By RCM in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 31, 2013, 1:46 PM
  3. GridPanel Get row cell values
    By naina in forum 1.x Help
    Replies: 7
    Last Post: Mar 10, 2012, 4:14 AM
  4. Replies: 1
    Last Post: Oct 24, 2011, 3:14 AM
  5. GridPanel getting Cell Values in RowSelection
    By EzaBlade in forum 1.x Help
    Replies: 5
    Last Post: Feb 03, 2009, 7:28 AM

Tags for this Thread

Posting Permissions