Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
272 views
I have a RadGrid with 2 inner layers of details tables.

I set this.radGrid.MasterTableView.HierarchyDefaultExpanded = true; before rebinding my grid for the export but it only expands 1 inner details table. How to expand all inner details tables? Thanks,
Pooya
Top achievements
Rank 1
 answered on 07 Apr 2011
5 answers
323 views
I am trying to accomplish using a single Radgrid for 7 different tables.  (one aspx page)  I am also wrapping my datasource updates (CRUD) in a Property procedure.  It is working pretty well except for inserting a new row in a table.  My problem is that it is posting the update to the radgrid control and the database twice,  I have spent many hours trying to debug my problem using the call stack and various other methods and what I have determined is that when I press the Insert link button (in-place editing), it is running the Radgrid_InsertCommand procedure twice and I am going slowly mad trying to figure out why.  My code is attached,  This could be a real challenge for the telerik MVPs. (or not!)  Thanks in advance.  (if I could, I would award 1000 points - but that's another site ;->)
P.S.  The Delete and Update commands work just fine using this code.  The difference is the insert process is activated from a RadButton outside the grid.  My aspx file has only the OnInsert, OnDelete, OnUpdate Commands.and the various SQLDataSources  The grid columns are built dynamically in code behind depending on the table the user chooses.
Protected Sub rgDisplay_InsertCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles rgDisplay.InsertCommand
        Dim editeditem As GridEditableItem = CType(e.Item, GridEditableItem)
        Dim dataTbl As DataTable = Me.GridSource
        Dim newRow As DataRow = dataTbl.NewRow
  
            Try 'calculate the next record key
                cmd.CommandText = "SELECT MAX(CMT_REC_ID) FROM tblTSComments"
                cmd.Connection = conn
                conn.Open()
                intLastKey = Convert.ToInt16(cmd.ExecuteScalar().ToString)
                intLastKey += 1
            Finally
                conn.Close()
            End Try
  
            Dim newValues As Hashtable = New Hashtable
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editeditem)
            Try
                For Each entry As DictionaryEntry In newValues
                    If entry.Key = "CMT_REC_ID" Then
                        newRow("CMT_REC_ID") = intLastKey
                    Else
                        newRow(entry.Key) = entry.Value
                    End If
                Next
                dataTbl.Rows.Add(newRow)
                Me.GridSource = dataTbl
            Catch ex As Exception
                ' Error message goes here
                e.Canceled = True
            End Try
    End Sub
Private Property GridSource As DataTable
        Get
            Dim obj As Object = Me.ViewState("_gvs")
            If (Not obj Is Nothing) Then
                Return CType(obj, DataTable)
            Else
                Dim intRpt As Integer = Request("Report")
                Select Case intRpt
                    Case 0 'Comments
                        adp.SelectCommand = New OleDbCommand("SELECT CMT_REC_ID, CMT_DESCRIPTION FROM tblTSComments", conn)
                        Dim cmtstbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(cmtstbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = cmtstbl
                        Return cmtstbl
                    Case 1 'Teams
                        adp.SelectCommand = New OleDbCommand("SELECT CT_TEAM_REC_ID, CT_TEAM_NAME, CT_REPORTS_TO FROM tblControllerTeam", conn)
                        Dim teamTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(teamTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = teamTbl
                        Return teamTbl
                    Case 2 'Status
                        adp.SelectCommand = New OleDbCommand("SELECT TCS_STATUS_CODE, TCS_DESCRIPTION FROM tblEmplStatus", conn)
                        Dim statusTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(statusTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = statusTbl
                        Return statusTbl
                    Case 3 'PayPeriod
                        adp.SelectCommand = New OleDbCommand("SELECT PAYPERIOD, PAYPERIODNBR, PAYPERIODLOCKED, PAYPERIODLOCKEDDATE, PAYPERIODLOCKID FROM PayPeriods ORDER BY PAYPERIOD", conn)
                        Dim ppTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(ppTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = ppTbl
                        Return ppTbl
                    Case 4 'Team Leader
                        adp.SelectCommand = New OleDbCommand("SELECT OPF_NTUSER_ID, OPF_FNAME, OPF_MINIT, OPF_LNAME, OPF_REGION FROM tblOpsFacilitator", conn)
                        Dim leadTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(leadTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = leadTbl
                        Return leadTbl
                    Case 5 'Vacation and Pers Choice Available
                        adp.SelectCommand = New OleDbCommand("SELECT TTE_NTUSER_ID, TTE_SOCIAL_SECURITY_NBR, TTE_FNAME + ' ' + TTE_LNAME AS NAME, TTE_TOTL_VAC_AVAIL, TTE_TOTL_PERS_CHOICE_AVAIL FROM tblTCCTimeCardEmployees WHERE TTE_EMPL_STATUS = 'A' ORDER BY TTE_NTUSER_ID", conn)
                        Dim vacPCHTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(vacPCHTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = vacPCHTbl
                        Return vacPCHTbl
                    Case 6 'Rates
                        adp.SelectCommand = New OleDbCommand("SELECT TTE_NTUSER_ID, TTE_SOCIAL_SECURITY_NBR, TTE_FNAME + ' ' + TTE_LNAME AS NAME, TTE_EMPL_CATEGORY, TTE_CALC_TIMESHEET, TTE_FIVE_PCNT_RATE, TTE_TEN_PCNT_RATE FROM tblTCCTimeCardEmployees WHERE TTE_EMPL_STATUS = 'A' ORDER BY TTE_NTUSER_ID", conn)
                        Dim rateTbl As New DataTable
                        conn.Open()
                        Try
                            adp.Fill(rateTbl)
                        Finally
                            conn.Close()
                        End Try
                        Me.ViewState("_gvs") = rateTbl
                        Return rateTbl
                End Select
            End If
        End Get
        Set(value As DataTable)
            Dim intRpt As Integer = Request("Report")
            Select Case intRpt
                Case 0 'Comments
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT CMT_REC_ID, CMT_DESCRIPTION FROM tblTSComments", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 1 'Teams
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT CT_TEAM_REC_ID, CT_TEAM_NAME, CT_REPORTS_TO FROM tblControllerTeam", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 2 'Status
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT TCS_STATUS_CODE, TCS_DESCRIPTION FROM tblEmplStatus", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 3 'PayPeriod
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT PAYPERIOD, PAYPERIODNBR, PAYPERIODLOCKED, PAYPERIODLOCKEDDATE, PAYPERIODLOCKID FROM PayPeriods ORDER BY PAYPERIOD", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 4 'Team Leader
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT OPF_NTUSER_ID, OPF_FNAME, OPF_MINIT, OPF_LNAME, OPF_REGION FROM tblOpsFacilitator", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 5 'Vacation and Pers Choice Available
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT TTE_NTUSER_ID, TTE_SOCIAL_SECURITY_NBR, TTE_FNAME + ' ' + TTE_LNAME AS NAME, TTE_TOTL_VAC_AVAIL, TTE_TOTL_PERS_CHOICE_AVAIL FROM tblTCCTimeCardEmployees WHERE TTE_EMPL_STATUS = 'A' ORDER BY TTE_NTUSER_ID", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
                Case 6 'Rates
                    Try
                        adp.SelectCommand = New OleDbCommand("SELECT TTE_NTUSER_ID, TTE_SOCIAL_SECURITY_NBR, TTE_FNAME + ' ' + TTE_LNAME AS NAME, TTE_EMPL_CATEGORY, TTE_CALC_TIMESHEET, TTE_FIVE_PCNT_RATE, TTE_TEN_PCNT_RATE FROM tblTCCTimeCardEmployees WHERE TTE_EMPL_STATUS = 'A' ORDER BY TTE_NTUSER_ID", conn)
                        Dim cmdBldr As OleDbCommandBuilder = New OleDbCommandBuilder(adp)
                        conn.Open()
                        adp.Update(value)
                    Catch ex As Exception
                        'Error during update, add code to locate error, reconcile and try again
                    Finally
                        conn.Close()
                    End Try
            End Select
        End Set
    End Property
  
    Protected Sub cmdAdd_Click(sender As Object, e As System.EventArgs) Handles cmdAdd.Click
        rgDisplay.MasterTableView.InsertItem()
    End Sub
End Class
Chuck Harrington
Top achievements
Rank 1
 answered on 07 Apr 2011
5 answers
202 views
Hi,
I am using Vertical RadSpliter  with 2 RadPane inside. But as I collapse the left pane, the collapse/resize button disappears and I cannot rezise this right pane. The left pane is also partially hidden by the vertical scroll bar.

I really need you help to solve the problem. This is very urgent.

Thanks,
Hai Tran
Hai
Top achievements
Rank 1
 answered on 07 Apr 2011
2 answers
79 views
Hi there,

I'm trying to develop an aspx website to dynamically generate HTML pages made up of predefined elements stored in a database.

Basically the generated pages consist of elements occupying 50% of the width of the page, and elements spanning 100%.
I'd like to create a drag and drop interface allowing users to drag the predefined elements to a 'layout' grid containing two columns. One for the left part of the generated html file, and one for the right part. The dropped elements should then be edited by the user so that he/she can input values like name and id for each dropped element.

Any suggestions which controlls to use and how to use them?
Thanks in advance.

Erik
Erik
Top achievements
Rank 1
 answered on 07 Apr 2011
1 answer
99 views

Hi,

I have a telrik grid which shows Hierarchical data in telrik grid. I want to populate one more grid(gridTeamMembers) in code below when user selects a row from detailtables ie groupID. I have problem selecting the groupID of Hierarchical  grid which I want to pass to the 3rd grid(gridTeamMembers). I want to use this groupID in SqlDataSource3 to populate the gridTeamMembers grid.

Please help. Here is my code.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <script type="text/javascript">
     //<![CDATA[
    

       var grid;

       function GridCreated() {
           grid = this;
       }

     
     
          //]]>
        </script>
       
   
</head>
<body>
    <form runat="server" id="mainForm" method="post">
      
     <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

        <telerik:RadSplitter ID="RadSplitter1" Width="700px" runat="server" Orientation="Vertical">
            <telerik:RadPane ID="gridPane" runat="server" Height="307px"
                Scrolling="None">
               

        <telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" ShowStatusBar="true" DataSourceID="SqlDataSource1"
            runat="server" AutoGenerateColumns="False" PageSize="7" AllowSorting="True" AllowMultiRowSelection="true"
            AllowPaging="True" GridLines="None">
            <PagerStyle Mode="NumericPages"></PagerStyle>
          
            <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="MainGroupID" AllowMultiColumnSorting="True">
          
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="GroupID" DataSourceID="SqlDataSource2" Width="100%"
                        runat="server">
                      
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="MainGroupID" MasterKeyField="MainGroupID" />
                        </ParentTableRelation>
                       
                        <Columns>
                            <telerik:GridTemplateColumn UniqueName="GroupID" DataField="GroupID">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" Font-Bold="true" Font-Italic="true" Text='<%# Eval("GroupID") %>' Visible="false" runat="server" />
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn SortExpression="GroupID" HeaderText="GroupID" HeaderButtonType="TextButton"
                                DataField="GroupID" UniqueName="GroupID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="GroupName" HeaderText="Group Name" HeaderButtonType="TextButton"
                                DataField="GroupName" UniqueName="GroupName">
                            </telerik:GridBoundColumn>                           
                        </Columns>
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="GroupName"></telerik:GridSortExpression>
                        </SortExpressions>
                      
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                   
                    <telerik:GridBoundColumn SortExpression="MainGroupID" HeaderText="MainGroupID" HeaderButtonType="TextButton"
                        DataField="MainGroupID" UniqueName="MainGroupID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="MainGroupName" HeaderText="MainGroup Name" HeaderButtonType="TextButton"
                        DataField="MainGroupName" UniqueName="MainGroupName">
                    </telerik:GridBoundColumn>
                   
                </Columns>
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="MainGroupName"></telerik:GridSortExpression>
                </SortExpressions>
                
            </MasterTableView>
            <ClientSettings EnablePostBackOnRowClick="true">
                            <Selecting AllowRowSelect="True" />
                        </ClientSettings>
        </telerik:RadGrid>

         </telerik:RadPane>
            <telerik:RadSplitBar CollapseMode="Both" ID="RadSplitBar2" runat="server" EnableResize="True">
            </telerik:RadSplitBar>
            <telerik:RadPane ID="listBoxPane" runat="server" CssClass="TextStyle" BackColor="#d9eeff">
               
                   <div id="divTeamMembers" style="height:260px;overflow-y:auto;padding:10px 10px 10px 10px; margin:10px 10px 10px 10px;">
                          <telerik:RadGrid ID="gridTeamMembers" runat="server"
                            DataSourceID="SqlDataSource3" Skin="Office2007"                            
                            AllowSorting="true" AllowPaging="false" AllowFilteringByColumn="false"
                            AutoGenerateColumns="false" ShowStatusBar="true" AllowMultiRowSelection="True"
                            Width="99%"
                            >
                                                   
                          
                           <MasterTableView Width="100%" DataKeyNames="MemID"
                                CommandItemDisplay="Top"    DataSourceID="dsTeamMemberInfo"
                                HorizontalAlign="NotSet"
                                AutoGenerateColumns="False"
                                AllowAutomaticUpdates="False"
                                AllowAutomaticInserts="False"
                                AllowAutomaticDeletes="False"
                                EditMode="PopUp">

                           

                            <Columns>
                              
                                <telerik:GridBoundColumn UniqueName="FirstName" DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" />
                                <telerik:GridBoundColumn UniqueName="LastName" DataField="LastName" HeaderText="Last Name" SortExpression="LastName" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" />
                              
                            </Columns>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true">
                            <Selecting AllowRowSelect="True" />
                             <ClientEvents OnGridCreated="GridCreated"></ClientEvents>                                                         
                        </ClientSettings>                                                           
                        </telerik:RadGrid>
                        </div>
                
            </telerik:RadPane>
        </telerik:RadSplitter>

        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM TestGroups"
            runat="server"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM TestGroups1 Where MainGroupID = @MainGroupID"
            runat="server">
            <SelectParameters>
                <asp:Parameter Name="MainGroupID" Type="string" />
            </SelectParameters>
        </asp:SqlDataSource>
       
        <!-- content end -->

        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:EIProfileConnectionString %>"
        SelectCommand="GetMemberDetail" SelectCommandType="StoredProcedure">
         <SelectParameters>
            <asp:ControlParameter ControlId="Radgrid1" Name="GroupID" PropertyName="SelectedValue" Type="Int32"/>
        </SelectParameters>
    </asp:SqlDataSource>
     
    </form>

</body>
</html>

Iana Tsolova
Telerik team
 answered on 07 Apr 2011
2 answers
590 views
Hello,

I do have a "asp image button" as a first column of radgrid and "caseNumber" viz CS123 as a second column and having hundreds of such rows.

I want to redirect to another page on clicking the image button in radgrid. like page1.aspx?ID=CS123

Can you please suggest me how I can achieve this ?

Thanks,
Prayag
prayag ganoje
Top achievements
Rank 1
 answered on 07 Apr 2011
2 answers
164 views
Hello Friends,

I have trouble on my project, and at moment I didn't get to solve it !! I have a grid and when I delete row for first time it is ok, the problem is if I delete the other line in sequence. For some reason, I can not delete any row where the ID is larger than the ID of the deleted first.

I am using telerik ajax Q3 2010 and my project is in C# Framework 4.0 !!

Could you help me with this case ??

See attached my code:

<div id="divListagem">
        <telerik:RadAjaxPanel ID="apListagem" runat="server" LoadingPanelID="lpListagem"
            Width="100%" HorizontalAlign="NotSet"
            meta:resourcekey="apListagemResource1">
            <telerik:RadGrid ID="dgListagem" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
                AllowSorting="True" GridLines="None" Skin="Windows7" EnableLinqExpressions="False"
                OnItemCommand="dgListagem_ItemCommand" OnItemDataBound="dgListagem_ItemDataBound"
                OnNeedDataSource="dgListagem_NeedDataSource" CellPadding="0" Height="100%" HorizontalAlign="Center"
                PageSize="20" meta:resourcekey="dgListagemResource" >
                <SortingSettings SortedAscToolTip="Ordem Crescente" SortedDescToolTip="Ordem Decrescente"
                    SortToolTip="Clique aqui para ordenar" />
                <GroupingSettings CaseSensitive="false" />
                <ClientSettings>
                    <Scrolling UseStaticHeaders="True" />
                </ClientSettings>
                <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="ID" ClientDataKeyNames="ID"
                    CellPadding="0" CellSpacing="0">
                    <Columns>
                        <telerik:GridTemplateColumn AutoPostBackOnFilter="True" DataField="ID" FilterControlWidth="60px"
                            GroupByExpression="ID Group By ID" HeaderText="Código" meta:resourcekey="gtCodigoResource"
                            ShowFilterIcon="false" SortExpression="ID" UniqueName="ID">
                            <ItemTemplate>
                                <asp:Literal ID="ltrId" runat="server"></asp:Literal>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="80px" />
                            <ItemStyle HorizontalAlign="Center" Width="80px" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn FilterControlWidth="180px" AutoPostBackOnFilter="True" DataField="Titulo" GroupByExpression="Titulo Group By Titulo"
                            HeaderText="Titulo" meta:resourcekey="gtTituloResource" ShowFilterIcon="False" SortExpression="Titulo"
                            UniqueName="Titulo">
                            <ItemTemplate>
                                <asp:Literal ID="ltrTitulo" runat="server"></asp:Literal>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn AutoPostBackOnFilter="True" DataField="Idioma" FilterControlWidth="180px"
                            GroupByExpression="Idioma Group By Idioma" HeaderText="Idioma" meta:resourcekey="gtIdiomaResource"
                            ShowFilterIcon="False" SortExpression="Idioma" UniqueName="Idioma">
                            <ItemTemplate>
                                <asp:Literal ID="ltrIdioma" runat="server"></asp:Literal>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="200px" />
                            <ItemStyle HorizontalAlign="Center" Width="200px" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="TemplateColumn">
                            <ItemTemplate>
                                <asp:HyperLink ID="hplEdit" runat="server" meta:resourcekey="hplEditResource" ImageUrl="/CMS/Estrutura/Image/lista_edit.png"></asp:HyperLink>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="19px" />
                            <ItemStyle HorizontalAlign="Center" Width="19px" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="TemplateColumn1">
                            <ItemTemplate>
                                <asp:ImageButton ID="ibtExcluir" runat="server" CommandName="Excluir" ImageUrl="/CMS/Estrutura/image/lista_delete.png"
                                    meta:resourcekey="ibtExcluirResource" />
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="20px" />
                            <ItemStyle HorizontalAlign="Center" Width="20px" />
                        </telerik:GridTemplateColumn>
                    </Columns>
                    <CommandItemTemplate>
                        <div class="CabecalhoBotaoGrid">
                            <table width="100%">
                                <tr>
                                    <td align="center">
                                          
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </CommandItemTemplate>
                </MasterTableView>
                <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default">
                </HeaderContextMenu>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
        <telerik:RadAjaxLoadingPanel ID="lpListagem" runat="server" Skin="Windows7" meta:resourcekey="lpListagemResource1">
            <div id="loading">
                <asp:Literal ID="ltrLoading" runat="server"
                    meta:resourcekey="ltrLoadingResource1"></asp:Literal>
            </div>
        </telerik:RadAjaxLoadingPanel>
    </div>


protected void dgListagem_ItemCommand(object sender, GridCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Excluir")
                {
                    GridEditableItem editeditem = (GridEditableItem)e.Item;
                    int codigo = Convert.ToInt32(editeditem.OwnerTableView.DataKeyValues[editeditem.ItemIndex]["ID"].ToString());
 
                    try
                    {
                        BLFaq.Delete(codigo);
                        dgListagem.Rebind();
                    }
                    catch
                    {
                        RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "showError", string.Format("javascript:alert('{0}')", txtErrorParent.Value), true);
                    }
                }
            }
            catch (Exception ex)
            {
                BAL.BLError.TrataErro(new Model.MLError() { Ex = ex, Page = this.Page });
            }
        }
 
        protected void dgListagem_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            try
            {
                dgListagem.DataSource = BLFaq.SelectListagem();
            }
            catch (Exception ex)
            {
                BAL.BLError.TrataErro(new Model.MLError() { Ex = ex, Page = this.Page });
            }
        }
 
        protected void dgListagem_ItemDataBound(object sender, GridItemEventArgs e)
        {
            var obj = e.Item.DataItem as MLFaq;
            if (obj == null) return;
 
            if (!(e.Item is GridDataItem)) return;
 
            GridDataItem item = (GridDataItem)e.Item;
            Literal control;
 
            //Id
            Literal ltrId = item.FindControl("ltrId") as Literal;
            ltrId.Text = obj.Id.ToString();
 
            //Titulo
            Literal ltrTitulo = item.FindControl("ltrTitulo") as Literal;
            ltrTitulo.Text = obj.Titulo;
 
            ////Texto
            //control = item.FindControl("ltrTexto") as Literal;
            //control.Text = obj.Texto;
 
            //Idioma
            Literal ltrIdioma = item.FindControl("ltrIdioma") as Literal;
            ltrIdioma.Text = obj.Idioma;
 
            //Editar
            var edit = item.FindControl("hplEdit") as HyperLink;
            var qs = new SecureQueryString();
            qs["IdItem"] = obj.Id.ToString();
            qs["indice"] = param.Index;
            qs["Update"] = Update.ToString();
            qs["Publish"] = Publish.ToString();
            qs["ItemMenuId"] = param.ItemMenuId.ToString();
            qs["MenuId"] = param.MenuId.ToString();
            qs["MenuName"] = param.MenuName;
 
            if (!Update)
            {
                edit.ImageUrl = "~/CMS/Imagens/pesquisar.png";
                edit.ToolTip = "Visualizar Cadastro";
            }
            else
            {
                edit.ToolTip = "Editar Cadastro";
            }
            edit.NavigateUrl = string.Format("Cadastro.aspx?IdItem={0}", qs);
 
            //Excluir
            var delete = item.FindControl("ibtExcluir") as ImageButton;
            if (!Delete)
            {
                delete.Enabled = false;
                delete.ImageUrl = "~/CMS/Estrutura/Image/lista_delete_off.png";
                delete.ToolTip = "Sem permissão para Excluir";
            }
            else
            {
                delete.ToolTip = "Excluir Registro" ;
                delete.OnClientClick = string.Format("javascript:return confirm('{0}');", txtMessage.Value);
            }
        }
 
    }
}

Daniel
Top achievements
Rank 1
 answered on 07 Apr 2011
1 answer
105 views
Hello Community,

I want to add my customized dialog. I followed the instructions mentioned here.
Unfortunately this doesn't work the way I want to. I guess the RadWindow.js is not available. Where do I find this file because an error occurs when I want to start the dialog and the editor.ShowDialog() throws the exception.
Does anybody know this issue?

Here are my files:

MyCustomDialog.html

<html>
    <head>
    <script type="text/javascript" src="./RadControls/Editor/Scripts/7_0_1/RadWindow.js"></script>
    <script type="text/javascript">
       InitializeRadWindow(); //this function is declared in the \RadControls\Editor\Scripts\<script_version>\RadWindow.js file
       alert(GetDialogArguments());
    </script>
    </head>
    <body>
        <table border="0" cellpadding="" cellspacing="0">
            <tr>
                <td>
                    <input type="text" style="width: 156px;" id="LinkURL" />
                </td>
            </tr>
        </table>
    </body>
</html>

ToolsFile.xml:

<root>
  <modules>
    <!--<module name="RadEditorDomInspector" />-->
  </modules>
  <tools name="MainToolbar">
    <!--<tool name="Print" shortcut="CTRL+P"/>-->
    <tool name="AjaxSpellCheck"/>
    <tool name="FindAndReplace" shortcut="CTRL+F"/>
    <tool name="Cut" />
    <tool name="Copy" shortcut="CTRL+C"/>
    <tool name="Paste" shortcut="CTRL+V"/>
    <tool name="PasteStrip"/>
    <tool separator="true"/>
    <tool name="Undo" shortcut="CTRL+Z"/>
    <tool name="Redo" shortcut="CTRL+Y"/>
    <tool name="CustomDialog" IconUrl="~/RadControls/Editor/Skins/Default/Buttons/Custom.gif" />
  </tools>
  <tools name="InsertToolbar" >
    <tool name="MOSSImageManager" shortcut="CTRL+G"/>
    <tool name="AbsolutePosition" />
    <tool separator="true"/>
    <tool name="FlashManager" />
    <tool name="MediaManager" />
    <!--<tool name="DocumentManager" />
    <tool name="TemplateManager" />-->
    <tool separator="true"/>
    <tool name="LinkManager" shortcut="CTRL+K"/>
    <tool name="Unlink" shortcut="CTRL+SHIFT+K"/>
    <tool name="MOSSLinkManager"/>
  </tools>
 
  <tools>
    <tool name="FormatBlock"/>
    <tool name="FontName" shortcut="CTRL+SHIFT+F"/>
    <!--tool name="FontSize" shortcut="CTRL+SHIFT+P"/-->
    <tool name="RealFontSize" shortcut="CTRL+SHIFT+P"/>
  </tools>
 
  <tools>
    <tool name="Superscript" />
    <tool name="Subscript" />
    <tool name="InsertParagraph" />
    <!--<tool name="InsertGroupbox" />-->
    <tool name="InsertHorizontalRule" />
    <tool name="InsertDate" />
    <tool name="InsertTime" />
  </tools>
 
  <tools>
    <tool name="ForeColor"/>
    <tool name="BackColor"/>
    <!--<tool name="ApplyClass"/>-->
    <tool name="FormatStripper"/>
  </tools>
 
  <tools name="DropdownToolbar">
    <tool name="InsertSymbol"/>
    <tool name="InsertTable"/>
    <tool name="InsertFormElement" />
    <!--<tool name="InsertSnippet"/>-->
    <tool name="ImageMapDialog"/>
    <!--<tool name="InsertCustomLink" shortcut="CTRL+ALT+K"/>
    <tool separator="true"/>
    <tool name="ConvertToLower" />
    <tool name="ConvertToUpper" />-->
    <tool separator="true"/>
    <!--<tool name="AboutDialog" />-->
    <tool name="Help" shortcut="F1"/>
    <tool name="Zoom"/>
    <!--<tool name="ModuleManager" />-->
    <tool name="ToggleScreenMode" shortcut="F11"/>
  </tools>
 
  <tools>
    <tool name="Bold" shortcut="CTRL+B"/>
    <tool name="Italic" shortcut="CTRL+I"/>
    <tool name="Underline" shortcut="CTRL+U"/>
    <tool name="StrikeThrough" />
    <tool separator="true"/>
    <tool name="JustifyLeft" />
    <tool name="JustifyCenter" />
    <tool name="JustifyRight" />
    <tool name="JustifyFull" />
    <tool name="JustifyNone" />
    <tool separator="true"/>
    <tool name="LineDistance1" />
    <tool name="LineDistance15" />
    <tool name="LineDistance2" />
    <tool separator="true"/>
    <tool name="Indent" />
    <tool name="Outdent" />
    <tool separator="true"/>
    <tool name="InsertOrderedList" />
    <tool name="InsertUnorderedList" />
    <tool name="ToggleTableBorder" />
    <tool separator="true"/>
    <tool name="SelectAll" shortcut="CTRL+A"/>
  </tools>
 
  <contextMenus>
    <contextMenu forElement="*">
      <tool name="Cut"/>
      <tool name="Copy"/>
      <tool name="Paste"/>
    </contextMenu>
    <contextMenu forElement="IMG">
      <tool Name="SetImageProperties" />
      <tool Name="ImageMapDialog" />
    </contextMenu>
    <contextMenu forElement="TABLE">
      <tool Name="ToggleTableBorder" />
      <tool Name="SetTableProperties" />
      <tool Name="DeleteTable" />
    </contextMenu>
    <contextMenu forElement="TD">
      <tool Name="InsertRowAbove" />
      <tool Name="InsertRowBelow" />
      <tool Name="DeleteRow" />
      <tool Name="InsertColumnLeft" />
      <tool Name="InsertColumnRight" />
      <tool Name="MergeColumns" />
      <tool Name="MergeRows" />
      <tool Name="SplitCell" />
      <tool Name="DeleteCell" />
      <tool Name="SetCellProperties" />
    </contextMenu>
    <contextMenu forElement="A">
      <tool Name="SetLinkProperties" />
      <tool Name="Unlink" />
    </contextMenu>
    <contextMenu forElement="BODY">
      <tool name="ForeColor"/>
      <tool name="BackColor"/>
      <tool name="Bold" shortcut="CTRL+B"/>
      <tool name="Italic" shortcut="CTRL+I"/>
      <tool name="Underline" shortcut="CTRL+U"/>
      <tool name="StrikeThrough" />
      <tool Name="Cut" />
      <tool Name="Copy" />
      <tool Name="Paste" />
      <tool Name="PasteFromWord" />
      <tool Name="PastePlainText" />
      <tool Name="PasteAsHtml" />
    </contextMenu>
    <contextMenu forElement="P">
      <tool name="ForeColor"/>
      <tool name="BackColor"/>
      <tool name="Bold" shortcut="CTRL+B"/>
      <tool name="Italic" shortcut="CTRL+I"/>
      <tool name="Underline" shortcut="CTRL+U"/>
      <tool name="StrikeThrough" />
    </contextMenu>
  </contextMenus>
 
  <cssFiles>
    <item name="/_wpresources/RadEditorSharePoint/5.8.7.0__1f131a624888eeed/Resources/bmuStylesRAD.css" />
  </cssFiles>
 
  <dialogParameters>
    <dialog name="CustomDialog">
      <parameter name="Param1" value="Value1" />
    </dialog>
  </dialogParameters>
</root>

MOSSEditorTools.js:

//...
Telerik.Web.UI.Editor.CommandList["CustomDialog"] = function(commandName, editor, oTool) {
    var args = null; //editor.GetDialogParameters(commandName);
    var argStr = "";
    //for (var item in args) {
    //    argStr += "[" + item + "=" + args[item] + "] ";
    //}
    alert("Custom dialog was called with the following arguments: " + argStr);
 
    editor.ShowDialog(
        "~/_wpresources/RadEditorSharePoint/5.8.7.0__1f131a624888eeed/Resources/MyCustomDialog.html"
        , args
        , 180
        , 80
        , null
        , null
        , "Custom Dialog");
}
Rumen
Telerik team
 answered on 07 Apr 2011
3 answers
213 views
I've got a webpart which fetches items and their ratings from an SharePoint list. 

I've managed to show the rating for each item using the RadRating control. I've looked into the assembly using the Object Explorer and found only one System.EventHandler, named Rate. I've tried attaching my own event handler to handle the logic of getting the new value and passing that over to SharePoint, but for some reason I can't seem to figure out how to get the event from rating an item.

Here's a code snippet including how I display the RadRating and try to catch the events when the User rates by using the RadRating:
foreach (SPListItem answerItem in answerListItems)                  
                    {                                            
                        Literal QAContent = new Literal();  
                        RadRating QARating = new RadRating();
                        QAContent.Text  = "<div class='qaAnswer'>";
 
                        //<Snip>
 
                        if (answerItem["Luokitus_x0020__x0028_0_x0020__x"] != null)
                        {
                            try {
                                string ratingValue = answerItem["Luokitus_x0020__x0028_0_x0020__x"].ToString();
                                QARating.Value = Int32.Parse(ratingValue);
                                QARating.AutoPostBack = true;
                                QARating.Rate += new EventHandler(QARating_Rate);                               
 
                                pnlQuestios.Controls.Add(QARating);
                                 
                            }
                            catch {}                           
                        }

                        QAContentEnd.Text += "</div>";
                        pnlQuestios.Controls.Add(QAContentEnd);
                    }

And here's my QARating_Rate where I've put a breakpoint into my foo string for testing...
protected void QARating_Rate(object sender, EventArgs e)
{
    string foo = "foo";
}

The thing is, while debugging and clicking the stars in the browser, it won't hit the QARating_Rate method ever. What am I doing wrong?
Niko
Telerik team
 answered on 07 Apr 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?