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

hierarchical grid programmatically

12 Answers 208 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 18 Jan 2011, 08:15 PM
I am adding the rows to the hierarchical grid programmatically from a collection. Can I edit the rows in the detail table in-line? do you have any examples?

Raja

12 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 19 Jan 2011, 11:43 AM
Hello,

I have followed your scenario and prepared a sample project for you demonstrating how the desired functionality can be implemented. You can find it attached to this message.

I hope it helps.

Best wishes,
Mira
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
RJ
Top achievements
Rank 1
answered on 20 Jan 2011, 02:12 AM
Hi Mira,

Sorry, I should have been little more clear. The detail table datasource is being bound at runtime (in the detailtabledatabind event) based on the data key from the  master table. The  detail table datasource is a list (collection of objects) and not all fields are shown in the grid. I would like to edit the row in the detail table with all the fields in the list (not just the fields that are shown in the grid). I would also like to validate some of the fields before updating in the updatecommand event. Is there any example that uses the webusercontrol with the edit form template. What is the best way to show all the fields during the update?

Thank You.
0
Mira
Telerik team
answered on 24 Jan 2011, 01:04 PM
Hello,

There should be no problem in using User Control Edit Form in hierarchical grid and show all desired fields. You can update the values as it is explained here.
Please take a look at the Validation help topic to see how to prevent the update operation if the user enters data in an edit field which is not in the correct format.

I hope this helps.

Kind regards,
Mira
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
RJ
Top achievements
Rank 1
answered on 25 Jan 2011, 03:41 AM

 

 

Hi Mira,

I have the EditFormSettings as EditFormType="Template". The form template has a few ASP text controls and two usercontrols. I couldn't find the user control when I tried with the code that was mentioned in the sample (see below). How can I find the user control in the template. Can I have user controls when EditFormType="Template".

Dim MyUserControl As UserControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)

 

 

 

 

 

 

 

Thank You.

 

0
Princy
Top achievements
Rank 2
answered on 25 Jan 2011, 10:41 AM
Hello,

Try the following approach to access the UserControl inside FormTemplate.

ASPX:
<EditFormSettings  EditFormType="Template">
    <FormTemplate>
       <asp:TextBox ID="GridtxtSearch" runat="server" Width="175px"></asp:TextBox>
       <uc1:GridUserControl ID="GridUserControl1" runat="server" />
    </FormTemplate>
</EditFormSettings>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem editItem = (GridEditFormItem)e.Item;
            UserControl userControl = (UserControl)editItem.FindControl("GridUserControl1"); //accessing userControl
            // .   .   .   .   .  .   .  .
         }
    }

Thanks,
Princy.
0
RJ
Top achievements
Rank 1
answered on 26 Jan 2011, 04:42 AM
Hi Princy,

Thank you and it worked. However I have a few more questions.

I have a radcombo in the UserControl. How can I bind this in the Form Template.
The CommandItemDisplay, shows add and refresh image. When I click on add, Form Template is displayed, but how can I get  radwindow instead of Form Template( the template is used only for editing).  Is there a way to remove the refresh image.

Thanks
0
Princy
Top achievements
Rank 2
answered on 27 Jan 2011, 11:45 AM
Hello,

You can access the RadComboBox in the Usercontrol and populate it.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem editItem = (GridEditFormItem)e.Item;
            UserControl userControl = (UserControl)editItem.FindControl("GridUserControl1"); //accessing userControl
            RadComboBox combo=(RadComboBox )userControl.FindControl("RadComboBox1");
           //populate combo
         }
    }

If you want to display RadWindow when clicking AddnewRecordButton, try the following approach.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridCommandItem)
       {
           GridCommandItem cmdItem = (GridCommandItem)e.Item;
           LinkButton btn = (LinkButton)cmdItem.FindControl("InitInsertButton");
           btn.Attributes.Add("onclick", "btnClick(); return false;");
       }
   }

Java Script:
<script type="text/javascript">
    function btnClick() {
        var oWnd = $find("<%=RadWindow1.ClientID%>");
        oWnd.show();//open RadWindow
    }
</script>

And inorder to hide Refresh button, you can set ShowRefreshButton property of CommandItemSettings as 'false'.

ASPX:
<MasterTableView CommandItemDisplay="Top" DataKeyNames="EmployeeID">
     <CommandItemSettings ShowRefreshButton="false" ></CommandItemSettings>

Thanks,
Princy.
0
Mira
Telerik team
answered on 27 Jan 2011, 11:59 AM
Hello,

if you want to use RadWindow for editing RadGrid records, please take a look at the Window Editing demo of the RadGrid. In it a DetailsView is used for displays the values. You can add a TemplateField with a RadComboBox to it in order to implement the desired functionality.

I hope this helps.

Kind regards,
Mira
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
RJ
Top achievements
Rank 1
answered on 27 Jan 2011, 02:35 PM
Thank You for your response. 

Is there anyway I can map the datafields to the textboxes in the user control so that the values will automatically be displayed during an edit.

Thank You.
0
RJ
Top achievements
Rank 1
answered on 28 Jan 2011, 02:12 AM
The AddnewRecordButton is not working. When Java Script is called, the Radwindow does not open and I still get the Insert template.

Thank you


0
Princy
Top achievements
Rank 2
answered on 28 Jan 2011, 06:52 AM
Hello RJ,

You can directly bind the TexTbox in UserControl like below.

ASPX:
<EditFormSettings  EditFormType="Template">
    <FormTemplate>
       <asp:TextBox ID="GridtxtSearch" runat="server" Width="175px"></asp:TextBox>
       <uc1:GridUserControl ID="GridUserControl1" runat="server" />
    </FormTemplate>
</EditFormSettings>

GridUserControl.ascx:
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("FirstName") %>'></asp:TextBox>

I am not sure why RadWindow is not showing when clicking AddNewRecordButton. Can you please paste your complete code for further assistance?

Thanks,
Princy.
0
RJ
Top achievements
Rank 1
answered on 11 Feb 2011, 04:30 AM
Hi,

I have a column in  the master table view which provides a count (records) of the detail table records. This column is the 4th column in the row. Is there a way to have the hierarchical button (plus sign) and the count in the 4th column for all the rows that have a count greater than zero.

Thank you.
Tags
Grid
Asked by
RJ
Top achievements
Rank 1
Answers by
Mira
Telerik team
RJ
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or