Dynamically assign column data.

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

MPF_COGNIZANT
Points 190
Replied On: Thu, Mar 15 2012 4:07 PM Reply

I am using UltrawebGrid and binding with a datasource in codebehind. I want to bind the ultrawebgrid columns based on the datasource values and also want to change the colour of that cell. Please advice how to proceed.

  • Post Points: 20

Verified Answer

Answered (Verified) Replied On: Mon, Mar 26 2012 6:12 AM Reply
Verified by MPF_COGNIZANT

Hi MPF_COGNIZANT,

Thank you for your reply.

I am attaching a sample for you demonstrating how the style of the whole checkbox column may be set, and how single cells from that column may be individually styled. Please note that when using columns of type "Checkbox", the input elements themselves do not exist and are not available on the server. Therefore if you need to style the checkboxes themselves differently, I would suggest that you consider using a templated column.

Feel free to contact me if you have any questions.

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


  • Post Points: 25

All Replies

Replied On: Mon, Mar 19 2012 7:33 AM Reply

Hi MPF_COGNIZANT,

Thank you for posting in the community.

In order to define the datasource field used for a column in UltraWebGrid, you may set the BaseColumnName property. For instance:

        UltraWebGrid1.Columns[0].BaseColumnName = "ID";
        UltraWebGrid1.DisplayLayout.AutoGenerateColumns = false;
        UltraWebGrid1.DataSource = populateGrid();
        UltraWebGrid1.DataBind();

The base column name can be dynamically/conditionally changed in order to implement your requirement. Styling individual cells may be done in the InitializeRow handler by accessing the style of the particular cell:

         e.Row.Cells[0].Style.ForeColor = System.Drawing.Color.Green;

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: 20
MPF_COGNIZANT
Points 190
Replied On: Mon, Mar 19 2012 9:05 AM Reply

Thank you for your response.

I would like assign Ultragrid column data based on dataset values. Not directly assigning datset to ultragrid. i did that based on below script.

 dtgtable.DisplayLayout.Rows(iCounter).Cells(0).Value .

But in this first i need to initialise grid with a dataset. Otherwise it is throwing object reference exception.

My second question is that i would like change the color of the control in the grid cell ( checkbox) dynamically based on the dataset values.Please advice the same.

  • Post Points: 5
MPF_COGNIZANT
Points 190
Replied On: Mon, Mar 19 2012 9:10 AM Reply

We are using ultragrid in much number of places in our application. Is there any easy methodology to upgrade it to webdatagrid or do we need to completely re-write the code? Please send with any examples.

  • Post Points: 20
Replied On: Thu, Mar 22 2012 7:58 AM Reply

Hi MPF_COGNIZANT,

Thank you for your reply.

Given that your grid is being bound to a datatable with the desired number of rows, you can dynamically set the cell values using the InitializeRow event as outlined above:

e.Row.Cells[0].Value = "some value";

Individually styling templated controls may be achieved at runtime by accessing the templated control for the respective row as described at:

http://forums.infragistics.com/forums/t/26392.aspx

Regarding the migration process, as the the new AIKIDO controls have a different architecture than that of the classic ones, the overall structure and API is changed. Therefore the migration process entails manually moving the implemented configuration of the old controls to the new ones. In terms of the functionality provided by the new toolset, we have made every attempt to ensure that all commonly used features of the classic suite are available as well. On that note, a detailed supposition between the features provided by our grids in particular may be found in the "Product Changes" blog:

http://community.infragistics.com/blogs/taz_abdeali/archive/2011/11/17/asp-net-product-changes-in-2011-volume-2.aspx

Rest assured you can expect our full support and assistance during the migration process should you decide to undertake it.

Please do not hesitate to contact me if you have any questions on that topic.

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


  • Post Points: 20
MPF_COGNIZANT
Points 190
Replied On: Fri, Mar 23 2012 9:15 AM Reply

Am thakful  you for your quick reply.

Regarding changing color of the control in the grid am creating dynamic columns. And not using any template . Check the same below.

dtgCOAEmailLog.Columns(0).Type =

 

ColumnType.CheckBox

dtgCOAEmailLog.Columns(0).AllowUpdate =

 

AllowUpdate.No

dtgCOAEmailLog.Columns(0).Width =

 

Unit.Pixel(70)

dtgCOAEmailLog.Columns(0).HeaderText =

 

"text1"

Please let me know how to proceed in this case.

  • Post Points: 20
Answered (Verified) Replied On: Mon, Mar 26 2012 6:12 AM Reply
Verified by MPF_COGNIZANT

Hi MPF_COGNIZANT,

Thank you for your reply.

I am attaching a sample for you demonstrating how the style of the whole checkbox column may be set, and how single cells from that column may be individually styled. Please note that when using columns of type "Checkbox", the input elements themselves do not exist and are not available on the server. Therefore if you need to style the checkboxes themselves differently, I would suggest that you consider using a templated column.

Feel free to contact me if you have any questions.

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


  • Post Points: 25
Replied On: Thu, Mar 29 2012 2:03 AM Reply

Hi MPF_COGNIZANT,

Please do not hesitate to contact me if you are experiencing any issues regarding this scenario.

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


  • Post Points: 20
MPF_COGNIZANT
Points 190
Replied On: Thu, Mar 29 2012 8:47 AM Reply

Am very grateful for your work.

 I can able to set the backcolor. But my requirement is forecolor. In other words i want check box check color. When i set forecolor of the column it is not reflecting. And am not able to find the control because am not using any template for grid. Is there any way or only option to use template?

 

  • Post Points: 20
Replied On: Mon, Apr 2 2012 2:59 AM Reply

Hi MPF_COGNIZANT,

Thank you for your reply.

If your requirement is to style the "tickmark" of a checkbox, this can be achieved for a checkbox by using CSS and some clientside scripting. A detailed guide for achieving that can be found at:

http://www.thecssninja.com/css/custom-inputs-using-css

As the checkboxes of a UltraWebGrid checkbox column are not available on the server, in this scenario it may be more practical to use a templated column.

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

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


  • Post Points: 20
MPF_COGNIZANT
Points 190
Replied On: Tue, Apr 3 2012 1:53 PM Reply

Thanks for your valuble infomation.

  • Post Points: 20
Replied On: Wed, Apr 4 2012 2:04 AM Reply

Hi MPF_COGNIZANT,

Thank you for your reply.

Please do not hesitate to contact me if I can be of assistance.

Best Regards,

Petar Ivanov
Developer Support Engineer
Infragistics, Inc.


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