Ultrawebgrid with UltragridColumn Format property

Answered (Verified) This post has 1 verified answer | 3 Replies | 2 Followers Thread's RSS feed.

Sati..
Points 160
Replied On: Tue, Jan 31 2012 6:45 AM Reply

How can I assign the Format="%" property of a UltraGridColumn in .cs file based on the value of ID.

I know that we can assign Format property in InitializeLayout layout event. But here we cannot access the data. So how can add a Format property based on the value of other column data.

This is basically assigning a format at cell level.

Any ideas on this?

  • Post Points: 20

Verified Answer

Answered (Verified) Replied On: Wed, Feb 1 2012 2:17 AM Reply
Verified by Sati..

Hi satishgondimalla,

Thank you for posting in the community.

The Format property of an UltraWebGrid column is applied to all items in that column. You could, however, style cells individually based on some condition using the InitializeRow handler. Here is a sample implementation which would set a currency format to cells in the third column where the cell values in the first column for that row are even:

    protected void UltraWebGrid1_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
    {
        if ( Int32.Parse(e.Row.Cells[0].Value.ToString()) %2 == 0) {
            e.Row.Cells[2].Value = String.Format("{0:c}", e.Row.Cells[2].Value);
        }
    }

Please note that the UltraWebGrid control is now outdated and as of .NetAdvantage 2011 Volume 2 is no longer included in our product package. I would suggest that you consider switching to the WebDataGrid/WebHieararchicalDataGrid. More information regarding these controls is available at:

http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=Web_WebDataGrid_WebDataGrid.html

Additional samples demonstrating the features of these grids can be found at:
http://samples.infragistics.com/aspnet/

Hope this helps.

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


  • Post Points: 40

All Replies

Answered (Verified) Replied On: Wed, Feb 1 2012 2:17 AM Reply
Verified by Sati..

Hi satishgondimalla,

Thank you for posting in the community.

The Format property of an UltraWebGrid column is applied to all items in that column. You could, however, style cells individually based on some condition using the InitializeRow handler. Here is a sample implementation which would set a currency format to cells in the third column where the cell values in the first column for that row are even:

    protected void UltraWebGrid1_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
    {
        if ( Int32.Parse(e.Row.Cells[0].Value.ToString()) %2 == 0) {
            e.Row.Cells[2].Value = String.Format("{0:c}", e.Row.Cells[2].Value);
        }
    }

Please note that the UltraWebGrid control is now outdated and as of .NetAdvantage 2011 Volume 2 is no longer included in our product package. I would suggest that you consider switching to the WebDataGrid/WebHieararchicalDataGrid. More information regarding these controls is available at:

http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=Web_WebDataGrid_WebDataGrid.html

Additional samples demonstrating the features of these grids can be found at:
http://samples.infragistics.com/aspnet/

Hope this helps.

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


  • Post Points: 40
Replied On: Mon, Feb 6 2012 4:34 AM Reply

Hi satishgonimalla,

Please feel free to contact me if you have any questions regarding this scenario.

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


  • Post Points: 5
Sati..
Points 160
Replied On: Mon, Feb 20 2012 6:31 AM Reply

Thanks for the sample. I made a tweak to get but it is still not working sometimes. Anyhow this looks good.

  • Post Points: 5
Page 1 of 1 (4 items) | RSS