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

I have an expanding grid with a self referencing hierarchy that can go to a variable depth so I can't use nested detail tables, so after some experimenting I started using the self referencing hierarchy and came up with the following code.

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"  
    OnDetailTableDataBind="RadGrid1_DetailTableDataBind" GridLines="None" 
    onitemdatabound="RadGrid1_ItemDataBound" >
    <MasterTableView DataKeyNames="ParentID, LearningObjectID, IsCriteria, ShowOverview, ShowNotes, ShowSchematic, LearningObject_Overview, LearningObject_Notes, SchematicFilename, OriginalSchematicFilename" AllowSorting="true" Width="100%" HierarchyLoadMode="ServerOnDemand" CommandItemDisplay="Top">
        <CommandItemTemplate>
            <asp:Table ID="tblInfo" runat="server">
                <asp:TableRow ID="rowOverview">
                    <asp:TableCell>
                        <asp:Label ID="ttlOverview" Font-Bold="true" Font-Size="Small" ForeColor="Black" runat="server" Text="Overview:"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Label ID="txtOverview" Font-Size="Small" ForeColor="Black" runat="server"></asp:Label>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow ID="rowNotes">
                    <asp:TableCell>
                        <asp:Label ID="ttlNotes" Font-Bold="true" Font-Size="Small" ForeColor="Black" runat="server" Text="Notes:"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Label ID="txtNotes" Font-Size="Small" ForeColor="Black" runat="server"></asp:Label>
                    </asp:TableCell>
                </asp:TableRow>                    
                <asp:TableRow ID="rowSchematic">
                    <asp:TableCell>
                        <asp:Label ID="ttlSchematic" Font-Bold="true" Font-Size="Small" ForeColor="Black" runat="server" Text="Schematic:"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:HyperLink ID="lnkSchematic" Font-Size="Small" ForeColor="Black" runat="server" Text="Click Here To View" Target="_blank" />
                        <asp:Label ID="txtSchematic" Font-Size="Small" ForeColor="Black" runat="server" Text="There is no schematic for this entry"></asp:Label>
                    </asp:TableCell></asp:TableRow></asp:Table></CommandItemTemplate><CommandItemSettings ExportToPdfText="Export to Pdf">
        </CommandItemSettings>
        <SelfHierarchySettings ParentKeyName="ParentID" KeyName="LearningObjectID" />
        <RowIndicatorColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn>
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
          
        <Columns>
            <telerik:GridImageColumn HeaderStyle-Width="20px" DataImageUrlFields="IconURL"></telerik:GridImageColumn>
            <telerik:GridBoundColumn DataField="Code" HeaderText="<%$ Resources:Code %>" 
                SortExpression="Code" UniqueName="Code" HeaderStyle-Width="100px" ItemStyle-Width="100px">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LearningObjective" 
                HeaderText="<%$ Resources:LearningObjective %>" SortExpression="LearningObjective" 
                UniqueName="LearningObjective">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="CriticalPercentage" 
                DataType="System.Double" HeaderStyle-Width="75px" ItemStyle-Width="75px" HeaderText="<%$ Resources:CriticalPercentage %>" ReadOnly="True" 
                SortExpression="CriticalPercentage" UniqueName="CriticalPercentage" DataFormatString="{0}%">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="NonCriticalPercentage" 
                DataType="System.Double" HeaderStyle-Width="75px" ItemStyle-Width="75px" HeaderText="<%$ Resources:NonCriticalPercentage %>" ReadOnly="True" 
                SortExpression="NonCriticalPercentage" UniqueName="NonCriticalPercentage" DataFormatString="{0}%">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
      
</telerik:RadGrid>
and the codebehind is
protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
{
    //Get the info on the parent item
    GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
    int LearningObjectID = (int)parentItem.GetDataKeyValue("LearningObjectID");
      
    //Get the info on the table that is to be opened.
    CMASDALTableAdapters.AssessUsersPositionSuitabilityTableAdapter assessment = new CMASDALTableAdapters.AssessUsersPositionSuitabilityTableAdapter();
    CMASDAL.AssessUsersPositionSuitabilityDataTable dt = assessment.GetAssessUsersPositionSuitability(int.Parse(Session["ClientID"].ToString()), EmployeeSelector1.SelectedPositionID, LearningObjectID, EmployeeSelector1.SelectedEmployeeID);
      
    //Check it has children
    if (dt.Count > 0)
    {
        //Find out if the children are criteria and therefore the bottom level and need the alternate table layout.
        if (dt[0].IsCriteria)
        {
            //Get the data for the new table layout
            CMASDALTableAdapters.AssessUsersPositionSuitabilityCriteriaTableAdapter assessment2 = new CMASDALTableAdapters.AssessUsersPositionSuitabilityCriteriaTableAdapter();
            e.DetailTableView.DataSource = assessment2.GetAssessUsersPositionSuitabilityCriteria(int.Parse(Session["ClientID"].ToString()), EmployeeSelector1.SelectedPositionID, LearningObjectID, EmployeeSelector1.SelectedEmployeeID);
            //Add the additional columns that I need to my collection.
            //Important: first Add column to the collection  
            GridBoundColumn nameColumn = new GridBoundColumn();
            e.DetailTableView.Columns.Add(nameColumn);
            //Then set properties  
            nameColumn.DataField = "AssessorName";
            nameColumn.HeaderText = "Assessor";
            nameColumn.HeaderStyle.Width = 150;
              
            //Important: first Add column to the collection  
            GridBoundColumn dateColumn = new GridBoundColumn();
            e.DetailTableView.Columns.Add(dateColumn);
            //Then set properties  
            dateColumn.DataField = "AssessmentDate";
            dateColumn.HeaderText = "Assessment Date";
            dateColumn.HeaderStyle.Width = 75;
            dateColumn.DataFormatString = "{0:d}";
              
            //Important: first Add column to the collection  
            GridBoundColumn statusColumn = new GridBoundColumn();
            e.DetailTableView.Columns.Add(statusColumn);
            //Then set properties  
            statusColumn.DataField = "AssessmentStatus";
            statusColumn.HeaderText = "Assessment Status";
            statusColumn.HeaderStyle.Width = 75;
            //Important: first Add column to the collection  
            GridBoundColumn method1Column = new GridBoundColumn();
            e.DetailTableView.Columns.Add(method1Column);
            //Then set properties  
            method1Column.DataField = "AssessmentMethod1";
            method1Column.HeaderText = "Assessment Method 1";
            method1Column.HeaderStyle.Width = 75;
            //Important: first Add column to the collection  
            GridBoundColumn method2Column = new GridBoundColumn();
            e.DetailTableView.Columns.Add(method2Column);
            //Then set properties  
            method2Column.DataField = "AssessmentMethod2";
            method2Column.HeaderText = "Assessment Method 2"; 
            method2Column.HeaderStyle.Width = 75;
            //Get rid of the columns I don't need.
            GridColumn critPercentageCol = e.DetailTableView.Columns[3];
            GridColumn nonCritPercentageCol = e.DetailTableView.Columns[4];
            e.DetailTableView.Columns.Remove(critPercentageCol);
            e.DetailTableView.Columns.Remove(nonCritPercentageCol);
            //GridColumn newCol = new GridColumn();
              
            //e.DetailTableView.Columns.Add();
        }
        else
            e.DetailTableView.DataSource = dt;
    }
    else
        e.DetailTableView.DataSource = dt;
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    //If its the command area prepare to show overview/notes etc.
    if (e.Item is GridCommandItem)
    {
        GridDataItem parentItem = e.Item.OwnerTableView.ParentItem as GridDataItem;
        if (parentItem != null)
        {
            //Get the information about the parent item
            bool showOverview = (bool)parentItem.GetDataKeyValue("ShowOverview");
            bool showNotes = (bool)parentItem.GetDataKeyValue("ShowNotes");
            bool showSchematic = (bool)parentItem.GetDataKeyValue("ShowSchematic");
            string strOverview = (string)parentItem.GetDataKeyValue("LearningObject_Overview");
            string strNotes = (string)parentItem.GetDataKeyValue("LearningObject_Notes");
            string lnkSchematicFilename = (string)parentItem.GetDataKeyValue("SchematicFilename");
            GridCommandItem commandItem = (GridCommandItem)e.Item;
            //Show and hide appropriate fields.
            if (showOverview)
            {
                Label txtOverview = (Label)commandItem.FindControl("txtOverview");
                txtOverview.Text = strOverview;
            }
            else
            {
                TableRow rowOverview = (TableRow)commandItem.FindControl("rowOverview");
                rowOverview.Visible = false;
            }
            if (showNotes)
            {
                Label txtNotes = (Label)commandItem.FindControl("txtNotes");
                txtNotes.Text = strNotes;
            }
            else
            {
                TableRow rowNotes = (TableRow)commandItem.FindControl("rowNotes");
                rowNotes.Visible = false;
            }
            if (showSchematic)
            {
                Label txtSchematic = (Label)commandItem.FindControl("txtSchematic");
                HyperLink lnkSchematic = (HyperLink)commandItem.FindControl("lnkSchematic");
                if (lnkSchematicFilename.Length == 0)
                    lnkSchematic.Visible = false;
                else
                {
                    lnkSchematic.NavigateUrl = lnkSchematicFilename;
                    txtSchematic.Visible = false;
                }
            }
            else
            {
                TableRow rowSchematic = (TableRow)commandItem.FindControl("rowSchematic");
                rowSchematic.Visible = false;
            }
        }
        else
            e.Item.Visible = false;
    }
    //if it's a criteria then hide the expand control
    if (e.Item is GridDataItem)// to access a row  
    {
        GridDataItem item = (GridDataItem)e.Item;
        RadGrid parentGrid = (RadGrid)sender;
        if ((bool)item.GetDataKeyValue("IsCriteria") == true)
        {
            item.Cells[0].Controls[0].Visible = false;
        }
    }
}

At first this approach seemed to work
Screenshot
but if I then expanded another row it would cut out my addidtional columns in my modified detail table.
Screenshot 2

Is it possible to modify a detail table view so that the changes persist on another row expanding?
Is there an easier/better way to do what I am attempting to do i.e. a self referencing grid with a different detail view at the lowest level?

Any help/advice will be gratefully received.

Jon

Iana Tsolova
Telerik team
 answered on 18 Nov 2010
1 answer
144 views

Hello
Maybe someone can help me with this little issue. Not really a bug deal but is somewhat annoying.

Here we go. I have deployed several RadWindows throughout my project as popup modal = true.
The window works well but here the catch. Whenever a button or control that fire the window is located within a update panel
Either ASP.net or RadAjax It  seem that the loading panel that is incorporated with the radwindow will not display.
What happens is that a blank widow appears fully opened as per setting and remain blank until the page loads.
Now if the control is outside as  update panel then the loading image load first and finally you get the PageLoad.
Is this related to full postback instead of a partial postback and is there any way around this???

Thanks in advance..

Georgi Tunev
Telerik team
 answered on 18 Nov 2010
1 answer
176 views

Hi,

I have to validate my RadComboBox with custom validator and if the validation is failed i have to set the style as the textbox image attached. Pls. Guide me how to achieve this.
 
Additional info: in text box we have the following code

textbox._invalid = true;
textbox.updateCssClass();

What is the similar one for RadComboBox.

Jidesh

Shinu
Top achievements
Rank 2
 answered on 18 Nov 2010
2 answers
67 views
Hi,
whether insert/edit mode, it needs the recurrence checkbox to be selected automatically with its other elements by default. how is it possible.
shashidhar ch
Top achievements
Rank 1
 answered on 18 Nov 2010
1 answer
204 views
Hi

I have a problem when i want to export RadGrid data into PDF format.
All non-english charachters (Hebrew) changes into '#' charachters.

I have received the answer concerning the question from you:

Hello Igor,

Please examine the Fonts / Unicode support section in the following topic:
PDF export

Let me know if you need more information.

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

I have read and I believe that it doesn't approach me.Ð’Ñ‹ can offer other decision of my problem?

Thanks
Igor

Daniel
Telerik team
 answered on 18 Nov 2010
3 answers
165 views
Hello guys,

I need a quick help regarding a situation where I have a RadGrid bound to a LinqDataSource and both have the Automatic CRUD enabled on them. The Grid renders and perform just as expected but instead of seeing icons for Update and delete, I'm seeing text. I want to have icons only. Kindly help!
Tsvetina
Telerik team
 answered on 18 Nov 2010
1 answer
144 views
on my button click i use
<P>strTXTFileBuilder</P>
to generate a text file in code behind on butten click event.
When I applied a radajaxloadingpanel on the button click i received javascrip error when the button is clicked. any idea how to make it work? thanks in advance
Line: 4723
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received 
from the server could not be parsed. Common causes for this error are when the 
response is modified by calls to Response.Write(), response filters, 
HttpModules, or server trace is enabled.<BR>Details: Error parsing near 
'filename 123'.
Pavlina
Telerik team
 answered on 18 Nov 2010
2 answers
395 views

Hello!
I ran into a problem that when the content inside edit form (pop-up window) of a grid is changing due some user actions (client-side), the pop-up window container keeps the same size. For example, if I use multipageview and tabstrip inside pop-up window, and content of the default tab has smaller height, than on other pages, when user switches tabs, the larger content goes out off the window.
Any chance I can manually resize the window ?

 

Thanks in advance!

Andy.

Andy
Top achievements
Rank 1
 answered on 18 Nov 2010
10 answers
739 views
1 ) Switching from:
<asp:Button ID="btnLookup" runat="server" Text="Lookup"  onclientclick="ShowLookupForm();" />
to RadButton:
<telerik:RadButton ID="Button1" runat="server" Text="Lookup"  AutoPostBack="false"
                     onclientclick="ShowLookupForm();"  >
                     <Icon PrimaryIconCssClass="rbSearch" PrimaryIconLeft="4" PrimaryIconTop="4"/>
                     </telerik:RadButton>
doesn't do anything when you click.
2) RadButton  doesn't work as Page.Form.DefaultButton when you press the enter key.

Georgi Tunev
Telerik team
 answered on 18 Nov 2010
1 answer
48 views
Hi. Over the weekend I was referred to Telerik as a solution for various controls that I need for a website that I'm developing. So far I am impressed but I am having some difficult with the RadGrid control. I will try to briefly summarise the problems and I would also greatly appreciate some guidance on how to do a couple of specific things (to save me a lot of learning time).

First I have looked at the demos. When I view the demo (link below) and set a filter criteria of ProductId = 1) the grid still displays 300,000 records but they appear to all be identical copies of the same record. Similar if I put a filter of (([Product Name] = "ch") and ([unit price] = 18)) then again the grid control says that it has 300,000 records but they appear to be a repeative set of two records (for productId 1 and 39). Is this a bug/correct?

http://demos.telerik.com/aspnet-ajax/grid/examples/performance/linq/defaultcs.aspx

I tried to get the RadGrid control working yesterday in a simple form. However, I was using an Access database and so an asp:accessdatasource control was create for the data source. However, I couldn't get it to work. I eventually switched to an SQLdatasource with exactly the same definition (including parameter definition) and it worked fine. Is this a bug/incompatibility between the RadGrid and asp:AccessDataSource?

When using the RadGrid with a datasource, the CRUD commands are defined in the datasource. However, they appear to work with or without the corresponding parameter definitions? Can anyone explain?

OK Those are the comments about my experience so far. I have two questions both of which are important for my development:

1.    If I have CRUD functionality on a grid can I pre-populate a new record with values and how do I do this? For example, a table may have a field [DateCreated] which I want to set to the date that the record was created. How can I do this within the grid?

2.    I want a table with a guid primary key field and then 3 text fields ([Title], {Description], [Content]). The Title and Description I want to edit with simple text boxes but the Content I want to create and edit with RadEditor. Is there an example that shows how to do this?

Many thanks
Tsvetina
Telerik team
 answered on 18 Nov 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?