[CLOSED] Custom parameter in grid column Renderer

  1. #1

    [CLOSED] Custom parameter in grid column Renderer

    Hi,

    We are creating a grid using dynamic columns from controller.

    I need to pass custom parameters(string[]) in grid column Renderer which would call RowActionBtnState() method from external JS file.

    Controller :
    string[] userRoles = new string[] { "role1", ""role2", "role3" };
    
    columns.Insert(0, new Column() { Text = "", DataIndex = "State_ID", Locked = true, Width = 40, Renderer = new Renderer() { Fn = "RowActionBtnState", FormatArgs = userRoles } });
    JS file code :
    var RowActionBtnState = function (value, meta, record, index, userRoles) {
        // Some Code
    };
    When I set a debugger inside RowActionBtnState() the userRoles parameter shows 1 everytime.

    Please suggest.
    Last edited by Daniil; Dec 16, 2013 at 3:12 AM. Reason: [CLOSED]
  2. #2
    Hi @alscg,

    You should use Handler instead of Fn.
    Handler = "return RowActionBtnState(value, metadata, record, rowIndex, 'userRoles');"
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @alscg,

    You should use Handler instead of Fn.
    Handler = "return RowActionBtnState(value, metadata, record, rowIndex, 'userRoles');"
    Daniil,

    Handler is working but the parameter 'userRoles' that i need to pass is an array of string as i mentioned in Controller section of previous post.

    Do we have any way to pass it to the function in JS file?
  4. #4
    Well, I used 'userRoles' as an example. You have to replace it with your real userRoles array.
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, I used 'userRoles' as an example. You have to replace it with your real userRoles array.
    Yes. I have already tried with concatenation as below :
    Controller :
    string[] userRoles = new string[] { "role1", ""role2", "role3" };
     
    columns.Insert(0, new Column() { Text = "", DataIndex = "State_ID", Locked = true, Width = 40, Renderer = new Renderer() { Handler = "return RowActionBtnState(value, metadata, record, rowIndex, '" + userRoles + "');" } });
    But in JS function i am receiving parameter value as "System.String[]".
  6. #6
    Hello!

    You need to serialize these values:

    string[] userRoles = new string[] { "role1", ""role2", "role3" };
      
    columns.Insert(0, new Column() { Text = "", DataIndex = "State_ID", Locked = true, Width = 40, Renderer = new Renderer() { Handler = "return RowActionBtnState(value, metadata, record, rowIndex, '" + JSON.Serialize(userRoles)+ "');" } });
  7. #7
    It worked.

    Thank you Baidaly.

Similar Threads

  1. [CLOSED] Grid Column Command...need Grid parameter!
    By rthiney in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 18, 2013, 9:11 PM
  2. Replies: 1
    Last Post: Dec 06, 2012, 3:27 PM
  3. Grid Column Renderer
    By karthik.arian03 in forum 1.x Help
    Replies: 8
    Last Post: Feb 11, 2011, 6:34 AM
  4. [CLOSED] number renderer in grid column
    By Vasudhaika in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 05, 2010, 10:01 AM
  5. [CLOSED] Grid Column Renderer for Currency £
    By CMA in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 07, 2010, 4:52 PM

Posting Permissions