Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
106 views
  1. I am trying to add/delete rows using on client(webmethods), but when the last row is deleted the

CommandItemDisplay is also getting deleted. 


2. Also the grid layout is changing when a row is deleted/added.
3. The Databinder expression for the years attended column does not work after rebind.

can you please point out the problems from the code below


Class:
 
public class Education
{
    #region Private fields
    private int? _ID;
    private string _Degree;
    private string _Program;
    private string _School;
    private DateTime _From;
    private DateTime _To;
    #endregion
 
    #region Constructors
    public Education()
    {
    }
    public Education(int ID, string Degree, string Program, string School, DateTime  From, DateTime  To)
    {
        this._ID = ID;
        this._Program = Program;
        this._Degree = Degree;
        this._School = School;
        this._From = From;
        this._To = To;
    }
    #endregion
 
    #region Public properties
 
    public int? ID
    {
        get
        {
            return this._ID.Value;
        }
        set
        {
            if ((this._ID != value))
            {
                this._ID = value;
            }
        }
    }
 
    public string Degree
    {
        get
        {
            return this._Degree;
        }
        set
        {
            if ((this._Degree != value))
            {
                this._Degree = value;
            }
        }
    }
 
    public string Program
    {
        get
        {
            return this._Program;
        }
        set
        {
            if ((this._Program != value))
            {
                this._Program = value;
            }
        }
    }
 
    public string School
    {
        get
        {
            return this._School;
        }
        set
        {
            if ((this._School != value))
            {
                this._School = value;
            }
        }
    }
 
 
    public DateTime From
    {
        get
        {
            return this._From;
        }
        set
        {
            if ((this._From != value))
            {
                this._From = value;
            }
        }
    }
 
    public DateTime To
    {
        get
        {
            return this._To;
        }
        set
        {
            if ((this._To != value))
            {
                this._To = value;
            }
        }
    }
 
    #endregion
}
 
ASPX:
 
  <telerik:RadGrid ID="RadGrid1" Width="489px" runat="server" Skin="Windows7"
                                            OnDataBound="RadGrid1_DataBound" OnItemCreated="RadGrid1_ItemCreated"
                                            OnPreRender="RadGrid1_PreRender">
                                            <MasterTableView CommandItemDisplay="Bottom" AutoGenerateColumns="False" CommandItemSettings-ShowRefreshButton="False"
                                                HeaderStyle-CssClass="gridHeader" CommandItemSettings-AddNewRecordText="Add"
                                                DataKeyNames="ID" ClientDataKeyNames="ID" ShowHeadersWhenNoRecords="true">
                                                <Columns>
                                                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn">
                                                        <ItemStyle />
                                                        <HeaderStyle Width="1%" HorizontalAlign="Center" />
                                                        <ItemStyle HorizontalAlign="Left" />
                                                    </telerik:GridEditCommandColumn>
                                                    <telerik:GridTemplateColumn UniqueName="ID" HeaderText="ID" ItemStyle-Width="1px">
                                                        <ItemTemplate>
                                                            <asp:Label ID="LblID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ID") %>'> ></asp:Label>
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="0%" HorizontalAlign="Left" />
                                                        <ItemStyle HorizontalAlign="Left" />
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn UniqueName="Degree" HeaderText="Degree" ItemStyle-Width="80px">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblDegree" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Degree") %>'> ></asp:Label>
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="12%" HorizontalAlign="Left" />
                                                        <ItemStyle HorizontalAlign="Left" />
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn UniqueName="Program" HeaderText="Program" ItemStyle-Width="80px">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblProgram" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Program") %>'>></asp:Label>
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="30%" HorizontalAlign="Left" />
                                                        <ItemStyle HorizontalAlign="Left" />
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn UniqueName="School" HeaderText="School" ItemStyle-Width="80px">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblSchool" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "School") %>'>></asp:Label>
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="37%" HorizontalAlign="Left" />
                                                        <ItemStyle HorizontalAlign="Left" />
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn UniqueName="YearsAttended" HeaderText="Years" ItemStyle-Width="80px">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblFrom" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "From","{0:yyyy}") + " - " + DataBinder.Eval(Container.DataItem, "To","{0:yyyy}") %>'></asp:Label>
                                                        </ItemTemplate>
                                                        <HeaderStyle Width="23%" HorizontalAlign="Left" />
                                                        <ItemStyle HorizontalAlign="Left" />
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" UniqueName="DeleteColumn">
                                                        <HeaderStyle Width="1%" HorizontalAlign="Center" />
                                                        <ItemStyle HorizontalAlign="Center" />
                                                    </telerik:GridButtonColumn>
                                                </Columns>
                                                <CommandItemTemplate>
                                                    <div style="padding-top: 3px; margin-top: 3px;">
                                                        <asp:LinkButton Style="vertical-align: bottom" ID="btnAddEducation" runat="server"
                                                            OnClientClick="return showEditEducation('Add');">
                                                   <img alt ="" src="Images/AddRecord.gif" style="border:0px;padding-left:2px;padding-right:5px;margin-top:0px;margin-top:-5px;"/>Add</asp:LinkButton>
                                                    </div>
                                                </CommandItemTemplate>
                                            </MasterTableView>
                                            <ClientSettings>
                                                <Selecting AllowRowSelect="true" />
                                                <ClientEvents OnRowSelected="rowSelected" />
                                                <Scrolling UseStaticHeaders="true" />
                                            </ClientSettings>
                                        </telerik:RadGrid>
 
 
Code Behind:
 
  protected void Page_Load(object sender, EventArgs e)
{
 educationList = new List<Education>();
        educationList.Add(new Education(0, "X", "General", "stanford", Convert.ToDateTime("1/1/1988"), Convert.ToDateTime("1/1/2000")));
  educationList.Add(new Education(0, "X", "General", "stanford", Convert.ToDateTime("1/1/1988"), Convert.ToDateTime("1/1/2000")));
  educationList.Add(new Education(0, "X", "General", "stanford", Convert.ToDateTime("1/1/1988"), Convert.ToDateTime("1/1/2000")));
  educationList.Add(new Education(0, "X", "General", "stanford", Convert.ToDateTime("1/1/1988"), Convert.ToDateTime("1/1/2000")));
  RadGrid1.DataSource = educationList;
        RadGrid1.DataBind();
}
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
             ((ImageButton)item["DeleteColumn"].Controls[0]).Attributes.Add("onclick", "deleteCurrent('" + item.ItemIndex + "');return false;");
        }
}
 
 
JavaScript:
 
 function deleteCurrent(index) {
                                    var grid = $find("<%= RadGrid1.ClientID %>");
                                    var MasterTable = grid.get_masterTableView();
                                    var row = MasterTable.get_dataItems()[index];
                                    id = row.getDataKeyValue("ID") //access DataKeyValue
                                    if (id != null) {
                                    PageMethods.DeleteEducationByID(id, updateGrid);
                                    }
                                    return false;
                                }
 
 
 
                                function updateGrid(result) {
                                    var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
                                    if (result != null) {
                                        tableView.set_dataSource(result);
                                        tableView.dataBind();
                                        var grid = $find("<%= RadGrid1.ClientID %>");
                                        grid.repaint();
                                    }
                                }
Vasil
Telerik team
 answered on 03 Jun 2011
1 answer
99 views

Hello,

I'm trying to create a reusable server control that will act as a "Help control" - it will render an image (or an image button) and will display a rich tooltip after clicking (or hovering) containing some help-related data. Since there can be a lot of content in the tooltip and there can be many of these controls on the page I would like to load the content only on demand - for instance from a Web Service.

I know that RadToolTip itself has no support for loading content from Web Service - I have to use RadToolTipManager or handle loading data on my own and use RadToolTip. What will be the best way (considering the performace and reusability) to achieve this : 

1. Each Help control creates a RadToolTipManager for itself

2. Assume that there is one RadToolTipManager (for instance in master page) and use it to display tooltips. (But how to access it since there is no RadToolTipManagerProxy)

3. Each Help control creates an empty RadToolTip for itselft, loads the content from web service on its own and when its loaded uses RadToolTip client side API to fill the tooltip with the content and show it.

Or maybe there is a better solution ?

Regards,

Jacek Toren

Svetlina Anati
Telerik team
 answered on 03 Jun 2011
1 answer
572 views
Hai,

This is my code :

<

 

telerik:RadWindow ID="RadWindowPopup" Width="1100px" Height="750px" Modal

="true"

 

 

 

Left="0" Top="0" EnableShadow="true" DestroyOnClose="true" Visible="true" Behaviors

="Close"

 

 

 

VisibleOnPageLoad="false" runat="server" Title="Local Item Request" Skin

="Web20">

 

 

 

</telerik:RadWindow

>

But it is showing in the default size(small window). I tried with only width and height , not giving other options. But still the same. Also, title is not the one which is given. Showing the pagename( of the page called in radwindow) as title.

Also, I have given only Close as Behaviors. But it is showing all Behaviors (Resize, Minimize, Close, Maximize, Move ) in the popup window.

I want a quick reply.

 

 

Shinu
Top achievements
Rank 2
 answered on 03 Jun 2011
1 answer
146 views

Hello All,

I want to use the RadScheduler in an ASP MVC application, only to display appointments. Appreciate any guidance such as code samples and/or tutorials on the matter.

Thanks in advance
Plamen
Telerik team
 answered on 03 Jun 2011
1 answer
121 views
Hello, I need to basically create validation to occur depending on the users selection of a RadPanelBar Child Item Selection.

So my issue is this. The user selects a button to move on to the next page, however, if they don't choose a child item of the panelbar then it causes an error when rendering the next page, so I would like to either disable the button depending on if the user has chosen a child item of the panel bar or display an error message that they need to select a child item in the panelbar before moving on, or both.

I assume that in order to accomplish this I am going to have to use Javascript? If so can anyone give me an idea of the code that I need to produce to accomplish my goal? I thank you for your help in advance.
Peter
Telerik team
 answered on 03 Jun 2011
1 answer
62 views
Hi,
I tried this example http://www.telerik.com/help/aspnet-ajax/panelbar-onclientitemcollapse.html.
Documentation says "The OnClientItemCollapse client-side event occurs after the user has collapsed a panel item.", but if RadPanelBar is collapsed and I click on RadPanelBar header (not on collapse/expand) arrow, OnClientItemCollapse also fires... Is this normal behaviour?

Regards Sid
Nikolay Tsenkov
Telerik team
 answered on 03 Jun 2011
5 answers
489 views
Scenario: I am performing multi level grouping using radgrid and when i click the expand icon it makes a postback. i wanted to avoid postback it should render content n when expand/collapse should not make a postback.

below is the code.
 
protected void Page_Init(object sender, EventArgs e)  
    {  
        RadGrid radGrid1 = new RadGrid();  
        radGrid1.ID = "radGrid1";  
        radGrid1.Skin = "Outlook";  
 
        radGrid1.DataSourceID = "SqlDataSource1";  
        radGrid1.GridLines = GridLines.None;  
 
        radGrid1.MasterTableView.GroupsDefaultExpanded = false;  
 
        GridGroupByExpression expression = new GridGroupByExpression();  
        GridGroupByField gridGroupByField = new GridGroupByField();  
        gridGroupByField = new GridGroupByField();  
        gridGroupByField.FieldName = "name";  
        gridGroupByField.HeaderText = "Name";  
        expression.SelectFields.Add(gridGroupByField);  
 
        gridGroupByField = new GridGroupByField();  
        gridGroupByField.FieldName = "name";  
        gridGroupByField.HeaderText = "Name";  
        expression.GroupByFields.Add(gridGroupByField);  
 
        GridGroupByExpression expression1 = new GridGroupByExpression();  
        gridGroupByField = new GridGroupByField();  
        gridGroupByField.FieldName = "Category";  
        gridGroupByField.HeaderText = "Category";  
        expression1.SelectFields.Add(gridGroupByField);  
 
        gridGroupByField = new GridGroupByField();  
        gridGroupByField.FieldName = "Category";  
        gridGroupByField.HeaderText = "Category";  
        expression1.GroupByFields.Add(gridGroupByField);  
        radGrid1.MasterTableView.GroupByExpressions.Add(expression);  
        radGrid1.MasterTableView.GroupByExpressions.Add(expression1);  
        this.PlaceHolder1.Controls.Add(radGrid1);  
 
 
    }  


Thanks a million...
Gaurav
Top achievements
Rank 1
 answered on 03 Jun 2011
0 answers
96 views
hi all
i have this jquery in my masterpage
$(document).ready(function () {
            $("#LoginDiv").toggle();
            $("#Button3").click(function () {
                $("#Button4").toggle();
            });
            $("#aLink").click(function () {
                $("#LoginDiv").toggle();
             });
 
        });
 but when i click on select check box of radlistview then my logindiv will appear.
this occur when i dont login to site.
how can i correct this?
thankful.
rastin
Top achievements
Rank 1
 asked on 03 Jun 2011
1 answer
74 views
Hi,

Please ignore previous image find below image attached.

Thanks
Peter
Telerik team
 answered on 03 Jun 2011
3 answers
440 views
I have a radgrid and I need to loop through (when the user hits a button) and check if the checkbox(es) has been selected and then get the ID to save into a variable.

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowSorting="True"
                    CellSpacing="0" GridLines="None" AutoGenerateColumns="False"
                    AllowMultiRowSelection="True" AllowPaging="True" PageSize="20" >
                    <GroupingSettings CaseSensitive="false" />
                    <MasterTableView ShowFooter="false" DataKeyNames="ID" AllowFilteringByColumn="True" >
                        <Columns>
                            <telerik:GridClientSelectColumn UniqueName="chbxSelection" />
                            <telerik:GridBoundColumn UniqueName="FirstName" SortExpression="First_x0020_Name" HeaderText="First Name"
                                DataField="First_x0020_Name" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" AllowFiltering="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="LastName" SortExpression="Last_x0020_Name" HeaderText="Last Name"
                                DataField="Last_x0020_Name" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" AllowFiltering="true">
                            </telerik:GridBoundColumn>
                             <telerik:GridBoundColumn UniqueName="Organization" SortExpression="Organization" HeaderText="Organization"
                                DataField="Organization" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" AllowFiltering="true">
                            </telerik:GridBoundColumn>
                             <telerik:GridBoundColumn UniqueName="Title" SortExpression="Title" HeaderText="Title"
                                DataField="Title" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" AllowFiltering="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="ID" Visible="false" DataField="ID" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </MasterTableView>
                    <ClientSettings>
                        <Selecting AllowRowSelect="true" />
                    </ClientSettings>
                </telerik:RadGrid>
Shinu
Top achievements
Rank 2
 answered on 03 Jun 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?