This is a migrated thread and some comments may be shown as answers.

[Solved] Problems with RadGrid

2 Answers 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
VS
Top achievements
Rank 1
VS asked on 21 Apr 2009, 05:34 AM

Hi,

I need to have a grid as shown below. The structure of the grid cannot be decided at design time coz columns A, B is not restricted to only those columns. There can be other columns like C,D, etc. So i am binding the records at runtime.
 I place the grid at designtime and set AutoGenerateColumns="True"

Name                                        A                                            B

Test1                                    valueA1    *                               valueB1    *
Test2                                    valueA2     *                               valueB2   *
Test3                                    valueA3     *                               valueB3   *
                    Bulk Update      Textbox1  UpdateButton1           Textbox2 UpdateButton2

I need the values in columns A,B,C,D,etc to display in textboxes when the page is displayed. ie: Textboxes displayed for A,B columns needs to be in a single line. I tried as

protected void rgTest_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)

{

if (e.Item is GridDataItem)

{ for (int i = 0; i < rgTest.PageSize; i++) {

rgTest.EditIndexes.Add(i); }

}}

This is working fine but the textboxes doesn't display in one line. For each rows, the textboxes are displayed in different lines.
1) Is this requirement possible? If so how?
2) At the end of the grid, for columns A,B,C etc needs textboxes for bulk update as shown above. So that, when i enter the value in the bulkupdate Textbox1 and click on UpdateButton1, all the textboxes in columnA should be updated with the value in the Textbox1. Similar for UpdateButton2, etc.. Is this possible? If so how?
3) * for each cell, will be an image button. It will be Delete and Update images. When the Delete image is clicked the corresponding textbox should be disabled. If Update is clicked, the corresponding textbox should be enabled. Is this possible?

Any help much appreciated.

Thanks

2 Answers, 1 is accepted

Sort by
0
VS
Top achievements
Rank 1
answered on 21 Apr 2009, 06:19 AM

I was able to solve Requirement No.1.

 

2) At the end of the grid, for columns A,B,C etc, i require textboxes for bulk update as shown in the main thread below. So that, when i enter the value in the bulkupdate Textbox1 and click on UpdateButton1, all the textboxes in columnA should be updated with the value in the Textbox1. Similar for UpdateButton2, etc.. Is this possible? If so how can i show an extra row in the grid with a textbox and button for each columns (A,B,C, etc) and when i click on update button, values needs to be updated only for that entire column
3) * for each cell, will be an image button. It will be Delete and Update images. When the Delete image is clicked the corresponding textbox should be disabled. If Update is clicked, the corresponding textbox should be enabled. Is this possible?

Any help will be much appreciated.

Thanks

0
Sebastian
Telerik team
answered on 24 Apr 2009, 07:46 AM
Hello Sujith,

Straight onto your questions:

  1. I assume that you found a solution on this one. The help topics linked below elaborate on the same subject:

    http://www.telerik.com/help/aspnet-ajax/grddefaulteditmodeforgriditemsoninitialload.html
    http://www.telerik.com/help/aspnet-ajax/grdputallitemsineditmodenoadditionalrebind.html
  2. You can place the textboxes and the buttons inside the grid footer (first you need to enable it by setting the ShowFooter property of the grid to true). This can be done dynamically injecting these controls in the footer cells inside the ItemCreated handler of the grid.

    For more details on this approach review the "Multi-line footer totals" paragraph of this help article (in your case you can insert the controls on ItemCreated and set their properties inside the ItemDataBound handler). To update the textboxes in the row, traverse the Items collection of the grid in the OnClick server handler of the update button and update the text in the cells of the column in question using the approach from the next paragraph.
  3. To change the enabled state of the textboxes depending on the clicked update/delete button in the row, you will need to reference the container item (GridEditableItem) from the OnClick server handler of the buttons, find the textbox inside the row and changes its state.

    These samples illustrate how to access RadGrid rows and controls inside them:
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/accessingcellsandrows/defaultcs.aspx

    http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html
    http://www.telerik.com/help/aspnet-ajax/gridreferencecontrolsinroweditform.html
Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
VS
Top achievements
Rank 1
Answers by
VS
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or