Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1115
How I can set cell attributes on server side?
posted

I have event InializeRow, HOw I can set cell attributes?

protected void PackageType_Grid_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
{

if (e.Row.Index == ((DataTable)PackageType_Grid.DataSource).Rows.Count - 1)
{
//I try this e.Row.Items.FindItemByKey("PackageName").Row.Attributes.Add("colspan", "7");
//I try this e.Row.Items.FindItemByKey("PackageName").Record.Attributes.Add("colspan", "7");

e.Row.Items.FindItemByKey("PackageName").Text = GetResourceText("MyPak_Miscellaneous_PackageName_Label");
}
}

Parents
No Data
Reply
  • 29417
    Verified Answer
    Offline posted

    Hello Anton ,

     Thank you for posting in our forum.

    You can’t apply any changes on the server side directly to the actual DOM elements the grid is going to render. Instead you would need to apply those changes on the client side on the grid’s initialize event.

    If this attribute need to be applied based on some condition that can only be checked on the server side you could use the row’s Tag property to mark specific rows that you want to apply the change to .

    You can set it in the InitializeRow event for example:   e.Row.Tag = "colspan";

    And on the client side you can check the tag of a row for example like this: sender.get_rows().get_row(i).get_tag();

    So for example you could iterate through the rows , get their tags and set the attribute you want. For example:

     

    function WebDataGrid1_Grid_Initialize(sender, eventArgs) {

     

                for (var i = 0; i < sender.get_rows().get_length(); i++) {

                    var currentRow = sender.get_rows().get_row(i);

                    if (currentRow.get_tag() == "colspan") {

                        currentRow.get_cell(0).get_element().colSpan = 2;

     

                    }

                }

            }

     

    Let me know if you have any questions or concerns.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://es.infragistics.com/support

     

Children