Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
171 views
Hi .
i have a radgrid and one level detail table.
i want hide detail button in specific condition.
for example row 1 has detail table but row 2 doesn't and ......
how it's possible ?
Princy
Top achievements
Rank 2
 answered on 01 Aug 2014
3 answers
237 views
Hi,
I have this template column which is calculating and showing the result of cost x quantity or alternatively quantity x Alternative Cost.
I would like to make this column sortable by clicking on the header but all I have tried up to now does not work.
I have tried to set the SortExpression but still does not sort, the header gets activated but there is no sorting.
Any help will be appreciated.
Thanks,
Felice


<telerik:GridTemplateColumn FilterControlAltText="Filter TotalCost column" HeaderText="Total Cost" UniqueName="TotalCost">
  <HeaderStyle Width="70px" />
  <ItemStyle HorizontalAlign="Right" />
</telerik:GridTemplateColumn>
 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
      if (e.Item is GridDataItem)
        {
            #region Calculate Total Cost
            //Get the special cost. If the value does not exist, it means the special cost is 0
            double specialcost = ((cell.Text.Trim()) != " " && !String.IsNullOrWhiteSpace(cell.Text.Trim())) ? double.Parse(cell.Text.Trim()) : 0;
            double cost = ((dataBoundItem["Cost"].Text.Trim()) != " " && !String.IsNullOrWhiteSpace(dataBoundItem["Cost"].Text.Trim())) ? double.Parse(dataBoundItem["Cost"].Text.Trim()) : 0;
            //If the special cost is 0 than total cost = cost * quantity
            if (specialcost == 0)
            {
                dataBoundItem["TotalCost"].Text = (cost * (Convert.ToDouble(dataBoundItem["Quantity"].Text))).ToString("N0");
            }
            else //If special cost exists than total cost = special cost * quantity
            {
                dataBoundItem["TotalCost"].Text = ((Convert.ToDouble(dataBoundItem["AlternCost"].Text)) * (Convert.ToDouble(dataBoundItem["Quantity"].Text))).ToString("N0");
            }
            #endregion
}
}
Shinu
Top achievements
Rank 2
 answered on 01 Aug 2014
1 answer
73 views
I have a radcombobox and a button control, i want to select a particular item in radcombo box on button click,completely through client side, can any one give me an example on how to implement it using javascript or jquery.If not possible then on server side.







Thanks

Sandeep
Shinu
Top achievements
Rank 2
 answered on 01 Aug 2014
3 answers
149 views
I am trying to not display(or remove or hide, etc.) a record when the nested grid for that record contains a certain value. How would I do this in the cs? If it does not contain that value then I would like to display it like it normally would. I have attached a screenshot to better display what I am trying to achieve.
Princy
Top achievements
Rank 2
 answered on 01 Aug 2014
2 answers
231 views
i have a series of "nested" child controls in a .net site.  i need to be able to use the client side api against telerik controls that are layered down in the nested controls from both the aspx page, and "parent' level controls - hope that makes sense.

I have done the same api work down one level, but not successful to date with multiple layers of nesting. 

thanks
Shinu
Top achievements
Rank 2
 answered on 01 Aug 2014
2 answers
186 views
Hello,

I'm trying to implement a pretty simple 3 level RadGrid(Master + 2 Detail) and no matter what I try I can't get it to display the 3rd level.  The first two levels expand properly, but the third just expands blank.  I'm sure I'm just missing something simple but wasn't sure where to look.  

Here's my Code:

01.<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" GridLines="None" ShowFooter="True" Skin="Forest" DataSourceID="SqlDataSourceRegion">
02.                <MasterTableView AutoGenerateColumns="true" DataKeyNames="region_id" ShowFooter="False">
03.                    <DetailTables>
04.                        <telerik:GridTableView runat="server" DataKeyNames="region_id" DataSourceID="SqlDataSourceCommunity" ShowFooter="False" AllowMultiColumnSorting="True" AllowSorting="True">
05.                            <DetailTables>
06.                                <telerik:GridTableView runat="server" DataKeyNames="community_id" DataSourceID="SqlDataSourceHomes" AllowSorting="True">
07.                                    <ParentTableRelation>
08.                                        <telerik:GridRelationFields DetailKeyField="community_id" MasterKeyField="community_id" />
09.                                    </ParentTableRelation>
10.                                </telerik:GridTableView>
11.                            </DetailTables>
12.                            <ParentTableRelation>
13.                                <telerik:GridRelationFields DetailKeyField="region_id" MasterKeyField="region_id" />
14.                            </ParentTableRelation>
15.                        </telerik:GridTableView>
16.                    </DetailTables>
17.                </MasterTableView>
18.            </telerik:RadGrid>
19.        </div>
20.        <br />
21.        <asp:SqlDataSource ID="SqlDataSourceRegion"
22.            ConnectionString="<%$ ConnectionStrings:LEAD %>"
23.            ProviderName="System.Data.SqlClient"
24.            SelectCommand="SELECT region_id, region_name FROM all_communities_regions_types " runat="server"></asp:SqlDataSource>
25. 
26.         <asp:SqlDataSource ID="SqlDataSourceCommunity"
27.            ConnectionString="<%$ ConnectionStrings:LEAD %>"
28.            ProviderName="System.Data.SqlClient"
29.            SelectCommand="SELECT c.community_id, c.name, r.region_id FROM all_communities c INNER JOIN all_communities_regions r ON c.community_id=r.community_id WHERE r.region_id=@region_id"
30.             runat="server">
31.            <SelectParameters>
32.                <asp:SessionParameter Name="region_id" SessionField="region_id" Type="string"/>
33.            </SelectParameters>
34.         </asp:SqlDataSource>
35.         
36.         <asp:SqlDataSource ID="SqlDataSourceHomes"
37.            ConnectionString="<%$ ConnectionStrings:LEAD %>"
38.            ProviderName="System.Data.SqlClient"
39.            SelectCommand="SELECT TOP 5 home_id, beds, bath, community_id FROM homes WHERE community_id = @community_id" runat="server">
40.            <SelectParameters>
41.                <asp:SessionParameter Name="community_id" SessionField="community_id" Type="string" />
42.            </SelectParameters>
43.        </asp:SqlDataSource>

Any thoughts?
-Jeff
Jeff
Top achievements
Rank 1
 answered on 31 Jul 2014
1 answer
109 views
I have a RadGrid that retrieve data on button click via Sql using a repository pattern.  When the downloadPDF button is used the PDF only display the header info.  The remainder of the pdf page is blank.   Below are my codes.  Your help is greatly appreciated.
<head runat="server">
 
 <title>Trader Position</title>
 
 <link href="../Content/CotUI.css" rel="stylesheet" />
 
 <script type="text/javascript">
  
 function requestStart(sender, args) {
 
 if (args.get_eventTarget().indexOf("DownloadPDF") > 0)
 
 args.set_enableAjax(false);
 
}
 
 </script>
  
</head>
<body>
 <form id="form1" runat="server">
 
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" AsyncPostBackTimeout="900"></telerik:RadScriptManager>
<div>
 
<asp:Button ID="ViewDataButton" runat="server" Text="View Trader Data" CssClass="blu-btn" ToolTip="Click to View Trader Data" OnClick="ViewDataButton_Click" />
</div>
<br />
 
<div id="TradersPositionDataGrid">
 
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Black">
 
</telerik:RadAjaxLoadingPanel>
 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="requestStart" DefaultLoadingPanelID="RadAjaxLoadingPanel1" UpdatePanelsRenderMode="Inline">
 
<AjaxSettings>
 
<telerik:AjaxSetting AjaxControlID="ViewDataButton">
 
<UpdatedControls>
 
<telerik:AjaxUpdatedControl ControlID="TraderRadGrid" ></telerik:AjaxUpdatedControl>
 
</UpdatedControls>
 
</telerik:AjaxSetting>
 
</AjaxSettings>
 
</telerik:RadAjaxManager>
 
<asp:ImageButton ID="DownloadPDF" runat="server" ImageUrl="~/Images/pdf-icon.png" OnClick="DownloadPDF_Click" />
 
<telerik:RadGrid ID="TraderRadGrid" runat="server" PageSize="500" AutoGenerateColumns="false" AllowPaging="true" Width="1100"
 
OnUpdateCommand="TraderRadGrid_UpdateCommand" OnItemCreated="TraderRadGrid_ItemCreated" >
 
<ExportSettings IgnorePaging="true" OpenInNewWindow="true" HideStructureColumns="true" >
 
<Pdf PageHeight="210mm" PageWidth="297mm" DefaultFontFamily="Arial Unicode MS" PageTopMargin="45mm"
 
BorderStyle="Medium" BorderColor="#666666">
 
</Pdf>
 
</ExportSettings>
 
<ClientSettings>
 
 <%--<Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>--%>
 
 <%--<Scrolling AllowScroll="false" UseStaticHeaders="false"></Scrolling>--%>
 
<Virtualization ItemsPerView="500" EnableVirtualization="true" EnableCurrentPageScrollOnly="true" InitiallyCachedItemsCount="2000" />
 
<Resizing AllowColumnResize="true" />
 
</ClientSettings>
 
<MasterTableView EditMode="InPlace" EnableNoRecordsTemplate="true" CommandItemDisplay="Top" AutoGenerateColumns="false" DataKeyNames="OWNER_ID">
 
<CommandItemSettings ShowAddNewRecordButton="false" />
 
<ColumnGroups>
 
<telerik:GridColumnGroup HeaderText="Futures" Name="FuturesInfo" HeaderStyle-HorizontalAlign="Center"></telerik:GridColumnGroup>
 
<telerik:GridColumnGroup HeaderText="Adjusted Options" Name="AdjOptionInfo" HeaderStyle-HorizontalAlign="Center"></telerik:GridColumnGroup>
 
</ColumnGroups>
 
<Columns>
 
<telerik:GridEditCommandColumn ButtonType="ImageButton"></telerik:GridEditCommandColumn>
 
<telerik:GridBoundColumn UniqueName="TraderId" DataField="OWNER_ID" HeaderText="Trader Id"></telerik:GridBoundColumn>
 
<telerik:GridBoundColumn UniqueName="TraderName" DataField="TRADER_NAME" HeaderText="Trader Name"></telerik:GridBoundColumn>
 
<telerik:GridBoundColumn UniqueName="ContractMarket" DataField="CONTRACT_MARKET_CODE" HeaderText="Contract Market"></telerik:GridBoundColumn>
 
<telerik:GridBoundColumn UniqueName="ExpirationDate" DataField="FUTURES_EXPIRATION_DATE" HeaderText="Expiration Date"></telerik:GridBoundColumn>
 
<telerik:GridBoundColumn UniqueName="FutureLong" DataField="FUT_LONG" HeaderText="Future Long" ColumnGroupName="FuturesInfo"></telerik:GridBoundColumn>
 
<telerik:GridBoundColumn UniqueName="FutureShort" DataField="FUT_SHORT" HeaderText="Future Short" ColumnGroupName="FuturesInfo"></telerik:GridBoundColumn>
 
<telerik:GridBoundColumn UniqueName="AdjOptionLong" DataField="ADJ_OPT_LONG" HeaderText="Adjusted Option Long" ColumnGroupName="AdjOptionInfo"></telerik:GridBoundColumn>
 
<telerik:GridBoundColumn UniqueName="AdjOptionShort" DataField="ADJ_OPT_SHORT" HeaderText="Adjusted Option Short" ColumnGroupName="AdjOptionInfo"></telerik:GridBoundColumn>
 
<telerik:GridBoundColumn UniqueName="CommercialFlag" DataField="COMMERCIAL_FLAG" HeaderText="Commercial Flag"></telerik:GridBoundColumn>
 
</Columns>
 
<EditFormSettings EditColumn-HeaderStyle-Width="50px">
 
<EditColumn ButtonType="ImageButton" />
 
</EditFormSettings>
 
</MasterTableView>
 
<PagerStyle AlwaysVisible="true" Mode="NextPrev"></PagerStyle>
 
</telerik:RadGrid>
 
</div>
 
</form>
 
</body>
 
</html>

 

 

bool isPdfExport = false;
 
        protected void DownloadPDF_Click(object sender, ImageClickEventArgs e)
        {
             
             
            isPdfExport = true;
            //TraderRadGrid.Rebind();
            //TraderRadGrid.MasterTableView.Rebind();      
            TraderRadGrid.MasterTableView.ExportToPdf();
             
        }

 

Again Thank You.

 

 

 













 

 

 


Ronald
Top achievements
Rank 1
 answered on 31 Jul 2014
4 answers
95 views
I am having one RadGrid and binding one Datatable to it From codebehind.
At each paging or sorting or drag drop column it goes server side (page refreshed) and then displays.
is there any professional way i can achieve this with faster speed.
my code is

<telerik:RadGrid ID="RadGridEmployeeCost" runat="server" AllowSorting="True" AllowPaging="true"
    AllowFilteringByColumn="true" CellSpacing="0" GridLines="None" HeaderStyle-Font-Bold="true"
    Skin="Web20" OnNeedDataSource="RadGridEmployeeCost_NeedDataSource" ShowGroupPanel="true"
    OnColumnCreated="RadGridEmployeeCost_ColumnCreated">
    <ClientSettings AllowDragToGroup="True" />
</telerik:RadGrid>

 AND
  protected void RadGridEmployeeCost_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
       {
               ObjCon.Open();
               SqlCommand ObjCmd = new SqlCommand("SELECT name,address,TelPhone,EmailId,Qualification FROM WorkSummary", ObjCon);
               ObjCmd.ExecuteNonQuery();
               SqlDataAdapter ObjDa = new SqlDataAdapter(ObjCmd);
               DataSet ds = new DataSet();
               ObjDa.Fill(ds);
               RadGridEmployeeCost.DataSource = ds;
           }
       }
 
protected void RadGridEmployeeCost_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
       {
           if ((e.Column is GridBoundColumn && e.Column.UniqueName == "TelPhone" || e.Column.UniqueName == "EmailId" || e.Column.UniqueName == "Qualification"))
           {
               GridBoundColumn column = e.Column as GridBoundColumn;
               column.AllowFiltering = false;
           }
       }

Jayesh Goyani
Top achievements
Rank 2
 answered on 31 Jul 2014
5 answers
553 views

In each row of a grid with EditType = "Row", I'm trying to show/hide the column editor controls based on data in that row. When some rows are in edit mode (after being clicked on), they will display a text box, checkbox, etc. approporiate for that particular row. Other rows will hide that option in the same column.
For the entire column, edit controls can be shown/hidden based on the column's ReadOnly field. Can this be turned on/off for individual rows?
Would prefer to handle this server-side. Trying to avoid managing dynamically added controls based on data conditions and instead simply turn on/off editing in specific cells of each row.

In the example below, when a row is in edit mode, I want the edit text box in the MilkType column to only display if the Product for that row is Milk. Otherwise the cell should be read-only when the row is in edit mode.

Thanks!
-Matt

(posting code separately - having problems submitting new thread with code blocks)

Matt
Top achievements
Rank 1
 answered on 31 Jul 2014
5 answers
425 views
Hello all,

I am having trouble with the calculated column. everything works well until the calculated column is added then I get error message "Identifier expected".

Have gone through the documentations and examples but cannot figure out what's wrong and why it's not working.
Here is the code below. Any insight would be appreciated. Thanks!



 
<telerik:RadGrid
     ID="ReportGrid"
     runat="server"
     DataSourceID="SearchResultDataSource"
 
         >
          
          
         <MasterTableView
         DataSourceID="SearchResultDataSource"
         AllowPaging="false"
 
         >
              
              
             <Columns>
                 
                                
                 <telerik:GridBoundColumn
                 DataField="name_last_first"
                 HeaderText="Name"
                  SortExpression="name_last_first"
                   UniqueName="name_last_first"
                                     
                     Aggregate="CountDistinct"
                      FooterAggregateFormatString="<b>{0:d}</b>"
 
                      />
 
                  
                 <telerik:GridNumericColumn
                 DataField="07" HeaderText="July"
                  SortExpression="07" UniqueName="07"
                   
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
                   />
 
 
 
                 <telerik:GridNumericColumn
                 DataField="08"
                 HeaderText="Aug" SortExpression="08"
                 UniqueName="08"                  
                
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
                 />
 
 
                 <telerik:GridNumericColumn DataField="09" HeaderText="Sept" SortExpression="09" UniqueName="09"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
               />
 
 
 
                 <telerik:GridNumericColumn DataField="10" HeaderText="Oct" SortExpression="10" UniqueName="10"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
               />
 
 
 
                 <telerik:GridNumericColumn DataField="11" HeaderText="Nov" SortExpression="11" UniqueName="11"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
               />
 
 
 
                 <telerik:GridNumericColumn DataField="12" HeaderText="Dec" SortExpression="12" UniqueName="12"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
               />
 
                 <telerik:GridNumericColumn DataField="01" HeaderText="Jan" SortExpression="01" UniqueName="01"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
                
               />
 
                 <telerik:GridNumericColumn DataField="02" HeaderText="Feb" SortExpression="02" UniqueName="02"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
                
               />
 
 
 
                 <telerik:GridNumericColumn DataField="03" HeaderText="Mar" SortExpression="03" UniqueName="03"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
                
               />
 
                
 
                 <telerik:GridNumericColumn DataField="04" HeaderText="April" SortExpression="04" UniqueName="04"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
                
               />
 
 
                 <telerik:GridNumericColumn DataField="05" HeaderText="May" SortExpression="05" UniqueName="05"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
                
               />
 
                 <telerik:GridNumericColumn
                 DataField="06"
                 HeaderText="June"
                  SortExpression="06"
                  UniqueName="06"
               Aggregate="Sum"
               FooterAggregateFormatString="<b>{0:d}</b>"
/>
 
 
 
          <telerik:GridCalculatedColumn
          HeaderText="Opened"
          UniqueName="Opened"           
          Aggregate="Sum" 
          FooterAggregateFormatString="<b>{0:d}</b>"
          DataFormatString="{0:d}"
          DataType="System.Int32"
          DataFields="01,02,03,04,05,06,07,08,09,10,11,12"
          Expression="{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}"                     
          />
    
 
             </Columns>
 
 
              <GroupByExpressions>
                  
                 <telerik:GridGroupByExpression>
                     <GroupByFields>
                        <telerik:GridGroupByField FieldName="unit_type" HeaderText=" " SortOrder="Ascending"  />
                     </GroupByFields>
                     
                     <SelectFields>
                         <telerik:GridGroupByField FieldName="unit_type" HeaderText=" " HeaderValueSeparator=" "  SortOrder="Ascending"  />
                     </SelectFields>
                 </telerik:GridGroupByExpression>
 
 
 
 
                 <telerik:GridGroupByExpression>
                     <GroupByFields>
                         <telerik:GridGroupByField FieldName="unit_name" HeaderText=" " SortOrder="Ascending"  />
                     </GroupByFields>
                                             
                     <SelectFields>
                         <telerik:GridGroupByField FieldName="unit_name" HeaderText=" " HeaderValueSeparator=" "  SortOrder="Ascending"  />
                     </SelectFields>
                 </telerik:GridGroupByExpression>
 
 
             </GroupByExpressions>
 
 
 
 
         </MasterTableView>
 
     </telerik:RadGrid>
 
 
 <asp:SqlDataSource ID="SearchResultDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
     SelectCommand="rpt_getOpenAndAssignedByMonthForUnit" EnableCaching="False" SelectCommandType="StoredProcedure">
 
     <SelectParameters>
    <asp:ControlParameter
    Name="int_fy"
    Type="Int32" 
    PropertyName="Text"
    ControlID="YearTxt"
    />
David
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 31 Jul 2014
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?