Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
76 views

I have  Radgrid with  6 columns

One of the column say 4th_col can have multiple rows within itself.
Basically the parent row id will be the key for retrieving the rows for 4th column.

I am doing inline editing on complet parent rows which means the 4ht column rows are also open.Now on top of that I should be able to add rows in the 4th column.

I hope I am clear

Do you have any sugesstions/ approaches?

Thanks

Marin
Telerik team
 answered on 22 Oct 2012
4 answers
86 views
I'm pretty sure I'm just doing something incorrectly, but here we go.

I'm trying to get a self-referencing hierarchy grid where the first grid and it's hierarchy is linked by ID and DirectParent and its second hierarchy is linked by ChildID and DirectParent so you'd have:
Ben
Ralph
Ralph's Age
Ralph's Eye Color
Betty
Ruth
Ruth's Height
Ruth's Shoe Size
David
David's Age
Sam
Beth
Beth's Blood Type

If the lines in the ASPX below are uncommented then the structure is there, but on the second level, it's like the entire data source just comes out on that line. If you leave in the commenting lines in then you can see what I want, but only for the first and second levels, but not the third. What am I doing wrong here? I also have this "MyRadGrid.MasterTableView.FilterExpression = "DirectParent IS NULL";" in the page load method. I've tried setting a filter on the detail tables, but nothing. Any suggestions are appreciated.

I'm working with a DataTable with Data that resembles this form:
Columns: ID, ChildID, Name, Value, DirectParent
myData.Rows.Add(0, 0, "Ben", "has no kids", DBNull.Value);
 
myData.Rows.Add(1, 0, "Ralph", "has no kids", DBNull.Value);
myData.Rows.Add(2, 0, "Betty", "is a mother", DBNull.Value);
myData.Rows.Add(3, 0, "David", "is a father", DBNull.Value);
 
myData.Rows.Add(0, 0, "Ralph's Age", "33", 1);
myData.Rows.Add(0, 0, "Ralph's Eye Color", "Red", 1);
myData.Rows.Add(0, 0, "David's Age", "77", 3);
 
myData.Rows.Add(0, 4, "Sam", "is David's son", 3);
myData.Rows.Add(0, 5, "Beth", "is David's daughter", 3);
myData.Rows.Add(0, 6, "Ruth", "is Betty's daughter", 2);
 
myData.Rows.Add(0, 0, "Beth's Blood Type", "O+", 5);
myData.Rows.Add(0, 0, "Ruth's Height", "82 inches", 6);
myData.Rows.Add(0, 0, "Ruth's Shoe Size", "10", 6);


And my ASPX is as follows

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <%-- Old, but working
            <rad:RadGrid runat="server" ID="MyRadGrid" OnNeedDataSource="MyRadGrid_NeedDataSource" MasterTableView-HierarchyLoadMode="Client" OnPreRender="MyRadGrid_PreRender">
                <MasterTableView HierarchyDefaultExpanded="true" HierarchyLoadMode="Client" DataKeyNames="TheParent, GUID" FilterExpression="TheParent = 0" ShowHeadersWhenNoRecords="false">
                    <SelfHierarchySettings ParentKeyName="TheParent" KeyName="GUID" MaximumDepth="3" />
                </MasterTableView>
                <ClientSettings AllowExpandCollapse="true"></ClientSettings>
            </rad:RadGrid>
            --%>
            <rad:RadGrid runat="server" ID="MyRadGrid" OnNeedDataSource="MyRadGrid_NeedDataSource" MasterTableView-HierarchyLoadMode="Client" OnPreRender="MyRadGrid_PreRender">
                <MasterTableView HierarchyDefaultExpanded="true" HierarchyLoadMode="Client" DataKeyNames="DirectParent, ID" ShowHeadersWhenNoRecords="false">
                    <SelfHierarchySettings ParentKeyName="DirectParent" KeyName="ID" MaximumDepth="3" />
                    <%--
                    <DetailTables>
                        <rad:GridTableView HierarchyDefaultExpanded="true" HierarchyLoadMode="Client" DataKeyNames="DirectParent, ChildID" ShowHeadersWhenNoRecords="false">
                            <SelfHierarchySettings ParentKeyName="DirectParent" KeyName="ChildID" MaximumDepth="1" />
                        </rad:GridTableView>
                    </DetailTables>
                    --%>   
                </MasterTableView>
                <ClientSettings AllowExpandCollapse="true"></ClientSettings>
            </rad:RadGrid>
        </div>
    </form>
</body>
</html>

Also, please excuse the structure of this DataTable. It isn't representative of any crazy database where IDs aren't unique.
Andrey
Telerik team
 answered on 22 Oct 2012
1 answer
213 views
I am attempting to load values in a RadComboBox inside a RadGrid and I am getting the following error -

"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control"

Here is the markup for the grid

<telerik:RadGrid runat="server" ID="rgrdClaimantStatus" 
    AutoGenerateColumns="False" 
    Skin="Windows7"  OnInt="InitializeGrid"
    Style="margin-top: 0px"
    OnNeedDataSource="rgrdClaimantStatus_NeedDataSource" 
    OnUpdateCommand="rgrdClaimantStatus_UpdateCommand"
    OnInsertCommand="rgrdClaimantStatus_InsertCommand" 
    OnDeleteCommand="rgrdClaimantStatus_DeleteCommand"
    OnItemCommand="rgrdClaimantStatus_ItemCommand"
    OnItemDataBound="rgrdClaimantStatus_ItemDataBound"   
    OnPreRender="rgrdClaimantStatus_PreRender" 
    OnItemCreated="rgrdClaimantStatus_ItemCreated"
    TabIndex="21"              
    >
    <MasterTableView commanditemdisplay="Top" EditMode="InPlace" ShowHeadersWhenNoRecords="True"
        <Columns>
            <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" ImageUrl="~/PPSPortal/images/Cancel.gif" UniqueName="DeleteColumn" ShowInEditForm="True" />
            <telerik:GridTemplateColumn UniqueName="StatusDesc" DataField="StatusDesc" HeaderText="Status" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                    <telerik:RadComboBox runat="server" ID="rcbClaimantStatusCode" Width="100"  Text='<%# Bind("StatusDesc")  %>'  />
                </ItemTemplate>                
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="DateFrom" DataField="DateFrom" HeaderText="Date From" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                    <telerik:RadDatePicker runat="server" ID="rdpClaimantStatusStartDate" width="150" DbSelectedDate='<%# Bind("DateFrom") %>'>
                        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
                        <DateInput DisplayDateFormat="M/d/yyyy" DateFormat="M/d/yyyy" TabIndex="2" />
                        <DatePopupButton ImageUrl="" HoverImageUrl="" TabIndex="2"></DatePopupButton>
                    </telerik:RadDatePicker
                </ItemTemplate>                
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="DateTo" DataField="DateTo" HeaderText="Date To" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                    <telerik:RadDatePicker runat="server" ID="rdpClaimantEndDate" width="150" onkeydown="ClaimantStatusEndDateKeyDown(this, event)" DbSelectedDate='<%# Bind("DateTo")  %>'>
                        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
                        <DateInput DisplayDateFormat="M/d/yyyy" DateFormat="M/d/yyyy" TabIndex="2" />
                        <DatePopupButton ImageUrl="" HoverImageUrl="" TabIndex="2"></DatePopupButton>
                    </telerik:RadDatePicker
                </ItemTemplate>                
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="DateCreated" DataField="DateCreated" HeaderText="Date Created" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                     <asp:Label runat="server" ID="lblClaimantDateCreated" Width="150" Text='<%# Bind("DateCreated")  %>' />
                </ItemTemplate>                
            </telerik:GridTemplateColumn>                                                            
            <telerik:GridTemplateColumn UniqueName="DateEdited" DataField="DateEdited" HeaderText="Date Edited" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                     <asp:Label runat="server" ID="lblClaimantDateEdited" Width="150" Text='<%# Bind("DateEdited")  %>' />
                </ItemTemplate>                
            </telerik:GridTemplateColumn>            
            <telerik:GridTemplateColumn UniqueName="ModifiedBy" DataField="ModifiedBy" HeaderText="Modified By" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                     <asp:Label runat="server" ID="lblClaimantModifiedBy" Width="150" Text='<%# Bind("ModifiedBy")  %>' />
                </ItemTemplate>                
            </telerik:GridTemplateColumn>                                                                      
        </Columns>
    </MasterTableView>
    <ClientSettings>              
        <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />
        <DataBinding EnableCaching="True" />
        <ClientEvents OnKeyPress="KeyPressed" />
    </ClientSettings>               
</telerik:RadGrid>

and here is the code that is binding the combo box

protected void rgrdClaimantStatus_ItemDataBound(object source, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        //SetEditModeColumnWidths(e.Item as GridDataItem);
        RadComboBox status = ((e.Item as GridDataItem)["StatusDesc"].FindControl("rcbClaimantStatusCode") as RadComboBox);
        LoadClaimantStatusList(status, Convert.ToInt32((GetSelectedCompany())));
      
    }
}

protected void LoadClaimantStatusList(RadComboBox rddlStatus, int companyId)
{
    ReferenceProcess rc = new ReferenceProcess();
    Dictionary<int,string> statusList = rc.GetClaimantStatusList(CentralDBConnString, companyId);
    rddlStatus.DataSource = statusList;
    rddlStatus.DataTextField = "Value";
    rddlStatus.DataValueField = "Key";
    rddlStatus.DataBind();
    rddlStatus.Items.Insert(0, new RadComboBoxItem("Select a status", string.Empty));
}

I had read in other threads about removing the DataBind() from the above code, but all that does is allow the load of the "Select A Status" item and none of the database items.

Thanks!
Nencho
Telerik team
 answered on 22 Oct 2012
6 answers
68 views
Hi,

Is it possible to Drag n drop multiple appointments across resources( using resource grouping) In Asp.Net Ajax Scheduler (Latest version or any ?)
Ravi
Top achievements
Rank 1
 answered on 22 Oct 2012
3 answers
239 views
Hola buen dia me gustaria saber como puedo incluir en la lista de los temas que viene por default mi tema pesonalizado con el biulder espeor me puedan ayudar para que asi lo pueda aplicar de una forma mas sencilla y facil
Bozhidar
Telerik team
 answered on 22 Oct 2012
2 answers
98 views
I have used two Rad Tab in my form
1st tab added some text field
2nd tab added Rad Grid. see my screen shot
Default row 5 is set then i have add row using addrow button to click.
When i click Add Row button to row create but previous row clear

This is my addrow coding:
private void addrow(int currow)//int currow
        {
            object[] emptyRow = new object[columcount];
            tabledata1 = null;
            DataTable dt = tabledata1;
            assigndt2(dt);
            dt.Rows.Add(emptyRow);
            RadGrid1.DataSource = dt;
            RadGrid1.DataBind();
        }

private void assigndt2(DataTable dt)
        {
            RadComboBox r1;
            RadNumericTextBox rn1;

            for (int i = 0; i <= RadGrid1.Items.Count - 1; i++)
            {
                if (dt.Rows.Count - 1 < i)
                {
                    object[] emptyRow = new object[columcount];
                    dt.Rows.Add(emptyRow);
                }
                r1 = (RadComboBox)this.RadGrid1.Items[i].FindControl("Workdesc");
                dt.Rows[i]["Workdesc"] = r1.Text;
                r1 = (RadComboBox)this.RadGrid1.Items[i].FindControl("Radcombo_Unit");
                dt.Rows[i]["Radcombo_Unit"] = r1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Quantity");
                dt.Rows[i]["Quantity"] = rn1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Rate");
                dt.Rows[i]["Rate"] = rn1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Amount");
                dt.Rows[i]["Amount"] = rn1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Fees");
                dt.Rows[i]["Fees"] = rn1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Total");
                dt.Rows[i]["Total"] = rn1.Text;


            }

        }
Tamim
Top achievements
Rank 1
 answered on 22 Oct 2012
1 answer
113 views
I'm having a logic issue.  I have some Comboboxes that I need to cascade while in Edit or Insert Mode.  The problem is when I Bind the second Combo based on the first, the entire Grid does a PostBack and so the Combos rebind again.

I know i'm likely just missing an 'If Postback' or something, but my brain is mush right now.

 

<telerik:RadGrid ID="RecipientsGrid" runat="server" AutoGenerateColumns="false" EnableViewState="true" PageSize="5" AllowFilteringByColumn="true" AllowPaging="true" AllowSorting="True">

<EditFormSettings EditFormType="Template">

<FormTemplate>

<telerik:RadComboBox ID="CountryCombo" runat="server">

 

</telerik:RadComboBox>

<telerik:RadComboBox ID="ProvinceCombo" runat="server" Width="325" >

</telerik:RadComboBox>

</FormTemplate>

</EditFormSettings>

</telerik:RadGrid>


    Private Sub RecipientsGrid_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RecipientsGrid.ItemDataBound
 
        If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
            Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
            Dim ProvinceCombo As RadComboBox = TryCast(editItem.FindControl("ProvinceCombo"), RadComboBox)
            Dim CountryCombo As RadComboBox = TryCast(editItem.FindControl("CountryCombo"), RadComboBox)
            Dim CityCombo As RadComboBox = TryCast(editItem.FindControl("CityCombo"), RadComboBox)
            '** Populate ComboBoxes and define their Default Value
            Using context As New DataEntities
                With CountryCombo
                    .DataValueField = "CountryId"
                    .DataTextField = "CountryName"
                    .DataSource = context.Countries.OrderBy(Function(x) x.displayOrder).ToList
                End With
                CountryCombo.Width = Unit.Pixel(320)
                CountryCombo.DataBind()
            End Using
 
            Using context As New DataEntities
                With ProvinceCombo
                    .DataValueField = "ProvinceId"
                    .DataTextField = "NameEnglish"
                    .DataSource = context.Provinces.Where(Function(x) x.CountryId = CountryId).OrderBy(Function(x) x.NameEnglish).ToList
 
                End With
                ProvinceCombo.Width = Unit.Pixel(320)
                ProvinceCombo.DataBind()
            End Using
 
 
            Using context As New DataEntities
                With CityCombo
                    .DataValueField = "CityId"
                    .DataTextField = "CityName"
                    .DataSource = context.Cities.Where(Function(x) x.ProvinceID = ProvinceId).OrderBy(Function(x) x.CityName).ToList
                End With
                CityCombo.Width = Unit.Pixel(320)
                CityCombo.DataBind()
            End Using
            SetComboBoxDefault(CountryId, CountryCombo, "Country")
            SetComboBoxDefault(ProvinceId, ProvinceCombo, "Province/State")
            SetComboBoxDefault(CityId, CityCombo, "City")
 
 
        End If
 
 
    End Sub
 
    Public Sub SetComboBoxDefault(ByVal FindItemByValue As Integer, ByVal Control As RadComboBox, ByVal DisplayText As String)
 
        Dim ComboBoxItem As RadComboBoxItem
 
        If FindItemByValue >0 Then
            ComboBoxItem = Control.FindItemByValue(FindItemByValue)
            ComboBoxItem.Selected = True
 
        Else
            Control.Items.Insert(0, New RadComboBoxItem("-- Please select a " & DisplayText & " --", String.Empty))
        End If
 
    End Sub
 
    Private Sub RecipientsGrid_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RecipientsGrid.ItemCreated
If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
 
            'if the item is in edit mode
            Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
            Dim CountryCombo As RadComboBox = DirectCast(editItem.FindControl("CountryCombo"), RadComboBox)
            CountryCombo.AutoPostBack = True
 
            AddHandler CountryCombo.SelectedIndexChanged, AddressOf CountryCombo_SelectedIndexChanged
 
        End If
 
 
    End Sub
 
    Protected Sub CountryCombo_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)
 
        If RecipientsGrid.MasterTableView.IsItemInserted <> False Then
 
            Dim insertItem As GridEditFormInsertItem = DirectCast(TryCast(sender, DropDownList).NamingContainer, GridEditFormInsertItem)
 
            Dim ddlList As DropDownList = DirectCast(insertItem.FindControl("Dropdownlist2"), DropDownList)
        Else
 
            Dim CountryCombo As RadComboBox = DirectCast(sender, RadComboBox)
            Dim editedItem As GridEditableItem = DirectCast(TryCast(sender, RadComboBox).NamingContainer, GridEditableItem)
            Dim ProvinceCombo As RadComboBox = DirectCast(editedItem.FindControl("ProvinceCombo"), RadComboBox)
 
            Using context As New DataEntities
                With ProvinceCombo
                    .DataValueField = "ProvinceId"
                    .DataTextField = "NameEnglish"
                    .DataSource = context.Provinces.Where(Function(x) x.CountryId = e.Value).OrderBy(Function(x) x.NameEnglish).ToList
                End With
                ProvinceCombo.Width = Unit.Pixel(320)
                ProvinceCombo.DataBind()
            End Using
 
        End If
 
    End Sub





Tsvetoslav
Telerik team
 answered on 22 Oct 2012
4 answers
133 views
I used radgrid view for display some of my data and using that rad view. I need to do two things
1. delete some records - need ajax manager
2. stream to web browser - need to disable ajax manager.

here is my code snipts 

<script type="text/javascript">
            function requestStart(sender, args) {
                if (args.get_eventTarget().indexOf("GD") > 0)
                    args.set_enableAjax(false);
            }
</script>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="requestStart">

in the grid
<%--<telerik:GridButtonColumn ButtonType="LinkButton" Text="<img src='../App_Themes/default/images/genDoc.gif' border='0' title='Generate Document'/>" UniqueName="GD" CommandName="G"></telerik:GridButtonColumn>--%>


<telerik:GridTemplateColumn HeaderText="" UniqueName="Image">
<ItemTemplate>
<asp:ImageButton ID="GD" runat="server" ImageUrl="~/App_Themes/Default/images/genDoc.gif" CommandName="1" OnClick="ImageButton1_Click">
</
asp:ImageButton>         
</
ItemTemplate><br></telerik:GridTemplateColumn>

in the code behind

  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
          if (e.CommandName == "G")
            {
                genDoc(e.Item.ItemIndex);
            }
        }

        protected void ImageButton1_Click(object sender, EventArgs e)                   //method 2
        {
            genDoc(0);
        }

If I use the commented link button thing it will go to the method run method well but not give me download a file. 
If I use image button it works well and I can download a file, but I cant get particular index to my method(e.Item.ItemIndex
)...{in the genDoc() - document.Save("Sample.doc", FormatType.Doc, Response, HttpContentDisposition.Attachment); }

any way what I want to pass e.Item.ItemIndex value to my method genDoc(int index)...Please help me. thanks

Shinu
Top achievements
Rank 2
 answered on 22 Oct 2012
3 answers
1.0K+ views
I'm having a hard time getting all of the column names for a tree list with javascript

I can call get_columns() and get an array of objects back, but they don't seem TreeListColumn objects - I can't call get_uniqueName() on them. I've dug around in the objects a bit in the debugger and I don't see the unique name in there at all.

Am I doing something wrong?
Princy
Top achievements
Rank 2
 answered on 22 Oct 2012
2 answers
537 views
Hi All,

           I am using RadAsyncUpload control in my program. I wanted to reduce the size of text box which comes with asyncupload control. Is it possible??? Here is my sample code.

<telerik:RadAsyncUpload runat="server" AllowedFileExtensions="jpg,png" ID="rdUploadImage" MultipleFileSelection="Disabled" MaxFileInputsCount="1" ControlObjectsVisibility="None" Width="1px" OnClientFileUploaded="ImageFileUploaded" InputSize="40" >
  <Localization Select="Browse" />
  </telerik:RadAsyncUpload>
  <style type="text/css">
  .RadUpload  .ruRemove 
  {
      display:none;
  }
  </style>

If anybody knows, kindly let me know the solution. Thanks in advance.
Geetha
Top achievements
Rank 1
 answered on 22 Oct 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?