Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
665 views
Hi everyone.
I've a problem with my TreeView controls. the problem is;

When I try to bind data from DB to RadTreeView, it gives this error : "This constraint cannot be enabled as not all values have corresponding parent values."

C# Code :

private void ForTree()
{
line 1:String Query = "SELECT * FROM dbo.FESTIVAL WHERE flag=0";
line 2:myDataTable3 = dtClass.GetQuery(Query);
        RadTreeView3.DataSource = myDataTable3;
        RadTreeView3.DataFieldID = "fest_id";
        RadTreeView3.DataValueField = "fest_id";
        RadTreeView3.DataFieldParentID = "cat_id";
        RadTreeView3.DataTextField = "title";
line 8:RadTreeView3.DataBind();   // This is the line where error occurs.


line 2 is connects to DB and fill the datatable from another class.

when I write the query  :"SELECT * FROM dbo.FESTIVAL", there was no problem but when I add it "WHERE flag=0" clause to filter some data at "line 1" it gives me error. And interesting point is When I change the Flag value to "1" (flag=1) it works fine !!,  it makes me crazy.

I search all the topics in "Telerik Forums" and there were some problems as mine, but my table is not spereated and all the Parent_id's values are "NULL"

so what can I do at this situation?

Database DataTable:

cat_id is a child_id. title column has some words will placed on node.

dbo.Festival
Fest_id   Cat_id  flag   title
1             NULL      0   
2             NULL      1
3             NULL      0    
4             NULL      1
5             NULL      0
6             NULL      1
7             NULL      0
8             NULL      1
9             NULL      0
10           NULL     1
11           NULL     0
12           NULL     1
13           NULL     0
14           NULL     1
15           NULL     0    
16           NULL     1
17           NULL     0    
18           NULL     1
19           NULL     0
20           NULL     1
21           1          0
22           1          1
23           1          0
24           1          1
25           2          0    
26           2         1
27           2         0
28           2         1
29           3         0
30           3         1
31          4          0
32           4          1
33           7          0    
34           7          1
35            8         0
36            8         1
37            9          0
38            9          1
39          10          0

...it goes until 180 records.
Vishnu
Top achievements
Rank 2
 answered on 14 Mar 2015
1 answer
79 views
The grid looks fine and when I sort a column the class name of my Serializable class gets added many time to the right.  Every time I press sort more text gets added. I have attached picture.

I am trying to add columns names at runtime since I do not know them in advanced.  My code is based on the Grid - Virtualization example and the documentation on columns Creating a Hierarchical Grid Programmatically.  It basically right out of the example and documentation.

My Asp:
<%@ Page Title="Group Administration" Language="C#" MasterPageFile="~/Organization.Master" AutoEventWireup="true" CodeBehind="GroupAdmin.aspx.cs" Inherits="SignupList.Admin.GroupAdmin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
 
    Administration
<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel"></telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel" LoadingPanelID="RadAjaxLoadingPanel" CssClass="demo-container">   
    <telerik:RadGrid ID="AdminGrid" OnNeedDataSource="AdminGrid_NeedDataSource" runat="server"
        Skin="Default" AutoGenerateColumns="false" AllowSorting="true" GroupingEnabled="false"
            EnableHeaderContextMenu="true" AllowPaging="true" PageSize="50">
 
        <ClientSettings ReorderColumnsOnClient="true" AllowColumnsReorder="true" ColumnsReorderMethod="Reorder">
                <Virtualization EnableVirtualization="true" InitiallyCachedItemsCount="2000"
                    LoadingPanelID="RadAjaxLoadingPanel" ItemsPerView="100"/>
                <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="500px" />
                <Resizing AllowColumnResize="true" />
            </ClientSettings>
            <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
 
    </telerik:RadGrid>
</telerik:RadAjaxPanel>
</asp:Content>

My aspx.cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
using SignupList.Com.SignupList;
using SignupList.Com.SignupList.Display.Models;
using Telerik.Web.UI;
 
namespace SignupList.Admin
{
    public partial class GroupAdmin : System.Web.UI.Page
    {
        protected void Page_Init(object source, System.EventArgs e)
        {
             DefineGridStructure(AdminGrid);
        }
 
        protected void Page_Load(object sender, EventArgs e) {
        }
 
        private static readonly Random Random = new Random();
         static string[] contactNames = new string[] { "Antonio Moreno", "Elizabeth Lincoln", "Hanna Moos", "Jaime Yorres", "Georg Pipps",
        "Pascale Cartrain", "Paul Henriot", "Matti Karttunen", "Patricio Simpson","Howard Snyder"};
        static string[] companyNames = new string[] { "Blauer See Delikatessen", "Folies gourmandes", "Hungry Coyote Import Store", "Let's Stop N Shop",
            "B's Beverages", "QUICK-Stop", "Split Rail Beer & Ale", "Wartian Herkku","Sant� Gourmet","Romero y tomillo" };
        static string[] contactTitles = new string[] { "Marketing Assistant", "Sales Associate", "Sales Agent", "Sales Representative",
            "Owner", "Sales Manager", "Accounting Manager","Marketing Manager","Sales Consultant","Accountant"};
        static string[] countries = new string[] { "Bulgaria", "USA", "Austria", "Germany", "Italy", "England", "Argentina", "Brazil", "France", "Spain" };
        static string[] ratings = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
 
        public List<Member> DataSource
        {
            get
            {
                object obj = Application["GroupAdminDataSource"];
                if (obj == null) {
                    List<Member> customers = new List<Member>();
                    for (int i = 0; i < 2000; i++)
                    {
                        int titlesIndex = Random.Next() % 10;
                        int companyIndex = Random.Next() % 10;
                        int contactIndex = Random.Next() % 10;
                        int ratingIndex = Random.Next() % 10;
                        int countryIndex = Random.Next() % 10;
                        Member customer = new Member();
                        customer.ID = (i + 1).ToString();
;
                        customer.Value1 = contactTitles[titlesIndex];
                        customer.Value2 = companyNames[companyIndex];
                        customer.Value3 = contactNames[contactIndex];
                        customer.Value4 = countries[countryIndex];
                        customer.Value5 = ratings[ratingIndex];
                        customers.Add(customer);
                    }
                    Application["GroupAdminDataSource"] = customers;
                }
                return (List<Member>)Application["GroupAdminDataSource"];
            }
            set
            {
                Application["GroupAdminDataSource"] = value;
            }
        }
 
       protected void AdminGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            AdminGrid.DataSource = DataSource;
        }
 
        [Serializable]
        public class Member
        {
            public string ID { get; set; }
            public string Value1 { get; set; }
            public string Value2 { get; set; }
            public string Value3 { get; set; }
            public string Value4 { get; set; }
            public string Value5 { get; set; }
        }
 
        private void DefineGridStructure(RadGrid adminGrid)
        {
            if (adminGrid.MasterTableView.Columns.Count > 1) {
                // exit if columns are already defined
                return;
            }
               
            adminGrid.MasterTableView.DataKeyNames = new string[] { "ID", "Value1", "Value2","Value3", "Value4", "Value5" };
 
            //Add columns
            GridBoundColumn boundColumn;
            boundColumn = new GridBoundColumn();
            boundColumn.UniqueName = "ID";
            boundColumn.DataField = "ID";
            boundColumn.HeaderText = "ID";
            boundColumn.HeaderStyle.Width = Unit.Pixel(50);
            adminGrid.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.UniqueName = "Value1";
            boundColumn.DataField = "Value1";
            boundColumn.HeaderText = "Full Name";
            adminGrid.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.UniqueName = "Value2";
            boundColumn.DataField = "Value2";
            boundColumn.HeaderText = "Display Name" ;
            adminGrid.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.UniqueName = "Value3";
            boundColumn.DataField = "Value3";
            boundColumn.HeaderText = "Email";
            adminGrid.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.UniqueName = "Value4";
            boundColumn.DataField = "Value4";
            boundColumn.HeaderText = "Commitment";
            adminGrid.MasterTableView.Columns.Add(boundColumn);          
            boundColumn = new GridBoundColumn();
            boundColumn.UniqueName = "Value5";
            boundColumn.DataField = "Value5";
            boundColumn.HeaderText = "Hours";
            boundColumn.HeaderStyle.Width = Unit.Pixel(50);
            adminGrid.MasterTableView.Columns.Add(boundColumn);          
 
        }
 
    }
}

No idea what the problem is.
George
Top achievements
Rank 2
 answered on 14 Mar 2015
3 answers
306 views
Hi,

how can I prevent files being overwritten in the target folder? 

<telerik:RadAsyncUpload runat="server" ID="txtAddFile" MultipleFileSelection="Disabled" AllowedFileExtensions="csv" />


Kind regards

Suzy
Ivan Danchev
Telerik team
 answered on 13 Mar 2015
5 answers
128 views
How do I append a PushButton to GridGroupHeaderItem. I see that I can add a button but I would like to keep the current text and also get a value for the button from the command arg if possible.

I can do the following in ItemCreated and ItemDatabound but it does not work as expected. This replaced the header text all together.

if (e.Item is GridGroupHeaderItem)
            {
                GridGroupHeaderItem header = (GridGroupHeaderItem)e.Item;
                Button lnkbtn = new Button();
                lnkbtn.ID = "Button1";
                lnkbtn.Text = "Click";
                header.DataCell.Controls.Add(lnkbtn);
            }

I have tried with header.Cells[0].Controls.Add(lnkbtn); and it kinda works but pushes the button onto a new line. I would like the button to the right of the group header text and if possible, all the way to the right side.

Thanks, Marty
moegal
Top achievements
Rank 1
 answered on 13 Mar 2015
1 answer
244 views
Hi all,

I'm having a trouble with a RadGrid and a DataSource.

I'm populating my datasource within the radGrid_NeedDataSource event. I'm using paging and filtering on my grid. I wanted to translate the content of a single column of my grid and I added some code within the NeedDataSource Event, like this (very summarized) :

// Getting the data from a custom CACHE
l_resource = CacheManager.Instance.GetResource(....);

// Translation process and assign dataSource to Grid.
myGrid.DataSource = TranslateDataSource(l_resource);

Due to huge amount of data, and a translation process being a bit slow, I realized that, when changing page, the grid calls again the NeedDataSource event and therefore, get the data and perform the translation process all over again. The problem is that, my query returns more than 100'000 elements and I display only 20 of them on the grid due to paging.

Now, here is what bugs me :

I either should download all the datas ONCE then give them to the data grid and never ask for a new datasource again when passing to a new page of my grid.
This process would give me a slow first load of the page then changing my grid's pages would be very quick...

...Or whenever I want another grid's page to display, I should send the specific informations so my query result is as small as possible. For example 20 items if my paging is 20 items, instead of 100000 items to display 20 items. It would therefore be optimized to display the correct amount of data within my grid.

I'm a bit surprized of this behavior and I would like to know what would be the best way to deal with that kind of problem.

Can you guys help me please ?

Stéphane
    
Viktor Tachev
Telerik team
 answered on 13 Mar 2015
3 answers
300 views
I have two grids. The first is a graphic selecting grid:

    <telerik:radwindow runat="server" id="rwGraphics" visibleonpageload="false">
        <ContentTemplate>
            <asp:UpdatePanel ID="Updatepanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Literal ID="GraphicType" runat="server" Visible="false" />
                    <asp:Literal ID="CurrentID" runat="server" Visible="false" />                     
            <asp:Literal ID="litJS" Runat="server"/>
            <div align='center'>
            <table width='300' cellpadding='0' >
            <tr>
            <td width='100%' colspan="3" align='left'>

                                <telerik:RadGrid ID="rg_graphics" runat="server" AllowSorting="true" AutoGenerateColumns="false" Width="100%" GridLines="Both" 
                                    BorderStyle="None" ShowFooter="false" ShowHeader="true" AlternatingItemStyle-BackColor="WhiteSmoke" AllowAutomaticInserts="false" restrictionzoneId="ContentTemplateZone" >    
                                    <HeaderStyle BackColor="#000084" Font-Bold="true" ForeColor="White" HorizontalAlign='left' />
                                        
                                            <MasterTableView OverrideDataSourceControlSorting="true" DataKeyNames="GraphicId" ShowHeader="false"  >
                        <Columns>
                                                    <telerik:GridButtonColumn ItemStyle-Wrap="false"  CommandName="AddGraphic" ButtonType="LinkButton" Text="Add File" />
                        </Columns>
                <ItemTemplate >
                <asp:hyperlink runat='server' id='hl_graphic' Target='_blank' CssClass='login' navigateurl='<%#getGraphicPath(DataBinder.Eval(Container.DataItem, "GraphicID"))%>'><%#DataBinder.Eval(Container.DataItem, "Description")%></asp:hyperlink>
                </ItemTemplate>
                                        </MasterTableView>
                                    </telerik:RadGrid><br />
               <asp:Label ID='l_noresults' Runat='server'><font color='firebrick'><b>No Graphics Found</b></font></asp:Label>
            </td>
            </tr>
            </table>
            </div>

                </ContentTemplate>
            </asp:UpdatePanel>
        </ContentTemplate>
    </telerik:radwindow>    


The next grid is what calls the first grid.  


<tr>
                <td class="RightAlignHeader" width="1%" nowrap="nowrap">Answers</td>
                <td>
                    <telerik:RadGrid ID="rg_Answers" runat="server" AllowSorting="true" AutoGenerateColumns="false" Width="100%" GridLines="Both" 
                        BorderStyle="None" ShowFooter="false" ShowHeader="true" AlternatingItemStyle-BackColor="WhiteSmoke" AllowAutomaticInserts="false" >    
                        <HeaderStyle BackColor="#000084" Font-Bold="true" ForeColor="White" HorizontalAlign='left' />
                        <MasterTableView OverrideDataSourceControlSorting="true" CommandItemDisplay="Top" AllowSorting="true" DataKeyNames="AnswerId"  ShowHeadersWhenNoRecords="true" CommandItemSettings-AddNewRecordText="Add New Answer">
                            <Columns>
                                <telerik:GridButtonColumn UniqueName="btnDelete"  Text="Delete" ConfirmText="Confirm delete?" ButtonType="LinkButton" CommandName="Delete" ItemStyle-Width="1%" />
                                <telerik:GridButtonColumn UniqueName="btnEdit" Text="Edit" ButtonType="LinkButton" CommandName="Edit" ItemStyle-Width="1%" />                                    
                                <telerik:GridBoundColumn UniqueName="Text" DataField="Text" HeaderText="Answers" ItemStyle-Wrap="false" SortExpression="Text"/>                
                                <telerik:GridCheckBoxColumn UniqueName="IsCorrect" DataField="IsCorrect" HeaderText="Correct" SortExpression="IsCorrect" DefaultInsertValue="False" />                
                                <telerik:GridImageColumn UniqueName="AnswerGraphic" HeaderText="Graphic"/>
                                <telerik:GridTemplateColumn Display="false" UniqueName="AnswerGraphicColumn"  >
                                    <EditItemTemplate>
                                        <asp:Label ID="lbAnswerGraphicPath" runat="server" />
                                        <asp:LinkButton CommandName="UpdateAnswerGraphic"  cssclass='login' Runat='server' ID="lbAddGraphic">Update Answer Graphic</asp:LinkButton>
                                    </EditItemTemplate> 
                                </telerik:GridTemplateColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid><br />
                 </td> 
            </tr> 

Whenever a user selects something from the first grid it triggers an itemcommand in which I can get the graphic ID of the row.
I want to be able to then add text to the label of the second grid "lbAnswerGraphicPath" and close the window for this first grid.
My problem is that I cannot seem to access the rg_Answers label "lbAnswerGraphicPath" from within the rg_graphics.ItemCommand event.

I have tried this code:

For Each item As GridDataItem In rg_Answers.Items
Dim TestLabel As Label = DirectCast(item("AnswerGraphicColumn").FindControl("lbAnswerGraphicPath"), Label)
Next

However the TestLabel object always returns as nothing.  How can I access this label (and change the text within) from the rg_graphics.itemcommand event?

Patrick
Top achievements
Rank 1
 answered on 13 Mar 2015
1 answer
160 views
Hi forum,

I want to give numbers as labels to the highlighted PlotBand area. Those labels should be from starting point to the end point and should be on the right yaxis.

Please see the attached file for example. The black lines on the right yaxis should be replaced by the numbers (label). Please provide help ASAP.

Thanks,

Jasdeep 
Danail Vasilev
Telerik team
 answered on 13 Mar 2015
8 answers
468 views
Hi,

Is it possible to somehow set the RadWindow to be always in maximized state?

I have a window which should be always maximized and I defined the window behaviours like the following. This works ok when I open the window at the first time but if I close the window and open it again it is in "normal" state and not maximized anymore.

    InitialBehavior

 

="Maximize"

 

 

    Behavior="Maximize"

Regards,
Pete

 

Hemant
Top achievements
Rank 1
 answered on 13 Mar 2015
1 answer
76 views
I have this issue where I am trying to change properties of the radskinmanager with javascript code but have failed to do so. I can't seem to figure out the code to grab that item.

The RadSkinManager is under the .master page on the asp project I don't know if that can be an issue, or if there is a special code to grab items from the .master page. The javascript is on a separate .js file

    anu.loadSkin = function () {
        alert("Im here");
    };
    window.onload = anu.loadSkin;

I can get it to alert on window onload but inside the method I want to change properties for the rad skin manager. Thanks!!
Angel Petrov
Telerik team
 answered on 13 Mar 2015
1 answer
142 views
How would I use .glyphicon-remove as the icon for the button on a RadNumericTextBox.

I see that I can upload a separate image but I would rather not since I am using bootstrap and it is already there.

I want to make the input clearable.

Marty
Venelin
Telerik team
 answered on 13 Mar 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?