Select Renderer function for Grid Column Code Behind (C#)

  1. #1

    Select Renderer function for Grid Column Code Behind (C#)

    Hello everyone, I would like to know if it is possible to use the renderer fn for a specific column, in code behind. Here is my code:

    <ColumnModel runat="server">
                                    ID="NameColumn" Text="Nombre Unidad"
                                    ID="Value10Col" Text="Fecha y hora"
                                    <Renderer Fn ="fixDate" />
    and on code behind i would like to change dynamically the renderer for 'Value7Col'. I currently have something like this:

     public void LoadInfo(string message)
                StoredProcedures sp = new StoredProcedures();
                var resultado = sp.getTDTReportsBySubmessage(message);
                if (message=="CONTROL CINTURÓN")
                    Value7Col.Text = "Estatus Cinturón";
                    //Renderer for the Column
                else if(message=="CONTROL PUERTA")
                    Value7Col.Text = "Estatus Puerta";
                    //Renderer for the Column
                var ordered = resultado.OrderBy(x => x.Name).ToList();
                TDTStore.DataSource = ordered;
    I would appreciate a lot any help or answer. Greetings from Mexico
    Last edited by fabricio.murta; Jan 05, 2016 at 5:43 PM. Reason: Wrap [code] tags around code.
  2. #2
    Hello @faridhajnal!

    Use Value7Col.Renderer.Fn = "myNewRenderer".

    Notice this works only when first loading the page.

    If you want to change the renderer after the page has already been loaded (during postback, for example), you have to do that from JavaScript side. Actually you'd better not change the renderer function itself, but you can make the function behave differently depending on the condition. For example a boolean. If this is what you want/need, there's some directions here: How to dynamically change column renderer of a grid column.

    To bring that ExtJS-specific answer to Ext.NET world, what you can do is setting a JavaScript global boolean variable to determine what the Value7Col renderer function should do, and then, in your code behind method. For example:

    In code behind method:
    X.AddScript("value7ColAlternativeRenderer = true");
    And have the renderer JavaScript function do something like this:
    if (value7ColAlternativeRenderer) {
     // Do the alternative renderer
    } else {
     // Do the main renderer
    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Thank you, it worked very nice!

Similar Threads

  1. Replies: 3
    Last Post: Dec 17, 2013, 12:19 PM
  2. Replies: 1
    Last Post: Dec 06, 2012, 3:27 PM
  3. [CLOSED] GridPanel. Force renderer function of column
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 25, 2012, 5:45 PM
  4. Grid Column Renderer
    By karthik.arian03 in forum 1.x Help
    Replies: 8
    Last Post: Feb 11, 2011, 6:34 AM
  5. [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

Tags for this Thread

Posting Permissions