Pass cell of Selection row in Grid via ExtraParms

  1. #1

    Pass cell of Selection row in Grid via ExtraParms

    Hello Masters
    i have a Grid that display some data , i wanna pass id to HttpPost action when user select row and then click the Button.
    i wrote this code for button in cshtml
                .Cls("numpad-btn two")
                 .Handler("App." + Wind + ".show(this);")        
                .DirectEvents(de =>
                    de.Click.Url =  Url.Action("InsertUpdate", "Role",new  {Area="Role"}); 
                    de.Click.ExtraParams.Add(new Parameter
                        Name = "roleId",
                        Value = "App.GridPanel1.selModel.getSelection().????",  //columns[0].val() 
                        Mode = ParameterMode.Raw,
                        Encode = true
    my code in controller is correct and Set up manually work['Id']
    but i dont Know how to set selected roleid in grid to ExtraParms.
    meanwhile user Select Row, not Cell;
    Last edited by orpheus; Dec 09, 2018 at 5:07 PM.
  2. #2
    Hello @orpheus!

    You already have the selection, but you can't get the value?

    Maybe you should just understand what you get with the Ext.selection.RowModel.getSelection() method.

    As for what I see you just need three steps there:
    - check if the result is an array with at least one entry (anything is selected, maybe error in case more than one are returned)
    - get what's the idProperty if you want to make a more generic solution (each entry will expose the getIdProperty() method)
    - fetch the actual value from the ID column of the data.

    For example, you could wrap up a 'get-value' function like this:

    function getGridSelectedId() {
      var grid = App.GridPanel1,
          selection = grid.getSelection();
      if (selection.length == 1) {
        var idField = selection[0].getIdProperty();
        return selection[0].get(idField);
      } else {
        Ext.toast("Invalid selection.");
        return false;
    Just to complicate things a bit (and make the code more robust, of course), you could fill the selection ID from the direct event's Before listener; if that event returns false, it will prevent the unnecessary server-side call. But then you'd best fill the extra-parameter from the Before event, and it would require another syntax (client-side) instead of the server-side syntax you're using in your code snippet.

    Well, hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    thanks it work with a little edition

Similar Threads

  1. MVC Grid Panel pass selected row cell value
    By OriCoder in forum 2.x Help
    Replies: 2
    Last Post: Jun 03, 2013, 4:09 AM
  2. Replies: 1
    Last Post: Mar 15, 2013, 1:33 AM
  3. pass parameter by selected row in grid panel
    By in forum 1.x Help
    Replies: 0
    Last Post: Dec 19, 2011, 12:05 PM
  4. Replies: 0
    Last Post: Sep 13, 2011, 7:59 AM
  5. get selected row in grid and pass to server side
    By Aleksa007 in forum 1.x Help
    Replies: 0
    Last Post: Mar 08, 2011, 12:58 AM

Posting Permissions