Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
76 views
I have a hierarchy grid and I want the master table to display a different color background if the underlying table has records. What is the best method for applying the formatting?
Mike Nogen
Top achievements
Rank 1
 answered on 09 Jan 2011
2 answers
287 views
Hi everyone and happy new year to all coders.

My problem is , I have a radgrid with custom paging, (based on Grid/Pager Template) i put a linkbutton and a textbox filter to load with data the radgrid 
When a write something to find in the textbox filter the radgrid it´s loaded correctly, the linkbutton it´s call one time.
When a click in the button (first, prev, next, last ) work ok to, but when I change the page size in the radcombox the RadGrid1_PageSizeChanged is called twice and if a write the number of the page in the RadNumericTextBox, the RadGrid1_PageIndexChanged it´s called one and then the LinkButton1_Click also.
Anyone can say what i am missing here?

I put here all the code.
Thank in advance.

Jolynice

ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="example.aspx.cs" Inherits="OralOffice_Pacientes_example" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div>
     <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
 
     <script type="text/javascript">
            var tableView = null;
            function pageLoad(sender, args) {
                tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
            }
 
            function RadComboBox1_SelectedIndexChanged(sender, args) {
                tableView.set_pageSize(sender.get_value());
            }
 
            function changePage(argument) {
                tableView.page(argument);
            }
 
            function RadNumericTextBox1_ValueChanged(sender, args) {
                tableView.page(sender.get_value());
            }
        </script>
 
    </telerik:RadScriptBlock>
 
            <!-- content start -->
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
 
            <div>
 
 
            <asp:Button ID="LinkButton1" runat="server"  Text="Find CompanyName" onclick="LinkButton1_Click">
            </asp:Button>  
            <input type="text" runat="server" name="fname" id="Text1"  style="width:370px;"/>
 
            </div>
 
            <telerik:RadGrid ID="RadGrid1" AllowPaging="true"
            DataSourceID="SqlDataSource1" runat="server" Skin="Vista"
            OnPageIndexChanged="RadGrid1_PageIndexChanged" onPagesizechanged="RadGrid1_PageSizeChanged">
                <MasterTableView>
                    <PagerTemplate>
                        <asp:Panel ID="PagerPanel" Style="padding: 6px; line-height: 24px" runat="server">
                            <div style="float: left">
                                <span style="margin-right: 3px;">Page size:</span>
                                <telerik:RadComboBox ID="RadComboBox1" DataSource="<%# new object[]{10, 20, 30, 40, 50} %>"
                                    Style="margin-right: 20px;" Width="40px" SelectedValue='<%# DataBinder.Eval(Container, "Paging.PageSize") %>'
                                    runat="server" OnClientSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                                </telerik:RadComboBox>
                            </div>
                            <div style="margin: 0px; float: right;">
                                Displaying page
                                <%# (int)DataBinder.Eval(Container, "Paging.CurrentPageIndex") + 1 %>
                                of
                                <%# DataBinder.Eval(Container, "Paging.PageCount")%>
                                , items
                                <%# (int)DataBinder.Eval(Container, "Paging.FirstIndexInPage") + 1 %>
                                to
                                <%# (int)DataBinder.Eval(Container, "Paging.LastIndexInPage") + 1 %>
                                of
                                <%# DataBinder.Eval(Container, "Paging.DataSourceCount")%>
                            </div>
                            <div style="width: 400px; margin: 0px; padding: 0px; float: left; margin-right: 10px;
                                white-space: nowrap;">
                                <asp:Button ID="Button1" runat="server"  OnClientClick="changePage('first'); return false;"
                                    CommandName="Page" CommandArgument="First" Text="|<" CssClass="PagerButton FirstPage" />
                                <asp:Button ID="Button2" runat="server" OnClientClick="changePage('prev'); return false;"
                                    CommandName="Page" CommandArgument="Prev" Text=" <" CssClass="PagerButton PrevPage" />
                                <span style="vertical-align: middle;">Page:</span>
                                <telerik:RadNumericTextBox ID="RadNumericTextBox1" Width="25px" Value='<%# (int)DataBinder.Eval(Container, "Paging.CurrentPageIndex") + 1 %>'
                                    runat="server">
                                    <ClientEvents OnValueChanged="RadNumericTextBox1_ValueChanged" />
                                    <NumberFormat DecimalDigits="0" />
                                </telerik:RadNumericTextBox>
                                <span style="vertical-align: middle;">of
                                    <%# DataBinder.Eval(Container, "Paging.PageCount")%>
                                </span>
                                <asp:Button ID="Button3" runat="server" OnClientClick="changePage('next'); return false;"
                                    CommandName="Page" CommandArgument="Next" Text=" >" CssClass="PagerButton NextPage" />
                                <asp:Button ID="Button4" runat="server" OnClientClick="changePage('last'); return false;"
                                    CommandName="Page" CommandArgument="Last" Text=" >|" CssClass="PagerButton LastPage" />
                            </div>
                            <asp:Panel runat="server" ID="NumericPagerPlaceHolder" />
                        </asp:Panel>
                    </PagerTemplate>
                    <PagerStyle Mode="NumericPages" PageButtonCount="10" />
                </MasterTableView>
            </telerik:RadGrid>
            <br />
            <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                ProviderName="System.Data.SqlClient"
                SelectCommand="SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City FROM Customers"
                runat="server"></asp:SqlDataSource>
            <!-- content end -->
    </div>
    </form>
</body>
</html>

C#
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class OralOffice_Pacientes_example : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            setdatasourceGrid();
            RadGrid1.DataBind();
        }
    }
 
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        setdatasourceGrid();
        RadGrid1.DataBind();
    }
 
 
    internal void setdatasourceGrid()
    {
        //To see the headers only
        if (String.IsNullOrEmpty(Text1.Value))
            SqlDataSource1.SelectCommand = "SELECT top 0 CustomerID, CompanyName, ContactName, ContactTitle  FROM  Customers ";
        //To see all records
        else if (Text1.Value.Equals("*"))
            SqlDataSource1.SelectCommand = "SELECT  CustomerID, CompanyName, ContactName, ContactTitle  FROM  Customers ";
        //filter
        else
            SqlDataSource1.SelectCommand = "SELECT CustomerID, CompanyName, ContactName, ContactTitle  FROM  Customers  WHERE  (CompanyName like  '%" + Text1.Value + "%')";
    }
 
 
    protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
    {
        RadGrid1.CurrentPageIndex = e.NewPageIndex;
        setdatasourceGrid();
        RadGrid1.DataBind();
    }
 
    protected void RadGrid1_PageSizeChanged(object source, Telerik.Web.UI.GridPageSizeChangedEventArgs e)
    {
        setdatasourceGrid();
        RadGrid1.DataBind();
    }
}

jolynice
Top achievements
Rank 1
 answered on 09 Jan 2011
2 answers
72 views
Hello Sir.

I would like to retrieve the value of the seletect row, i have  AllowKeyboardNavigation="true"   and i catch the key enter  
<ClientEvents OnRowDblClick="RowDblClick" OnKeyPress="KeyPress"></ClientEvents>  

When the enter key is pressed i want to go to another detail page based of the value of the row selected.

With RowDblClick i achived correctly but with the event onKeypress i don´t.

Can you help me.

Thanks.


  function RowDblClick(sender, eventArgs)
 {                       
             PacienteId = eventArgs.getDataKeyValue("CustomerID"));
 }

function KeyPress(sender, eventArgs)
{
  ?????????
}

jolynice
Top achievements
Rank 1
 answered on 09 Jan 2011
3 answers
156 views
Hi All,

I have some strange behaviours with the toolbars in the editor.
See the attached images.

The toolbar in the back (screen1) is only showing when you change the default toolstrip, removed the font button

<telerik:RadEditor ID="edtClosed" runat="server" EditModes="Design" EnableResize="False"
                    Height="100px" Language="nl-NL" Width="500px">
                    <Tools>
                        <telerik:EditorToolGroup Tag="MainToolbar">
                            <telerik:EditorTool Name="FindAndReplace" />
                            <telerik:EditorSeparator />
                            <telerik:EditorSplitButton Name="Undo" Width="80px">
                            </telerik:EditorSplitButton>
                            <telerik:EditorSplitButton Name="Redo" Width="80px">
                            </telerik:EditorSplitButton>
                            <telerik:EditorSeparator />
                            <telerik:EditorTool Name="Cut" />
                            <telerik:EditorTool Name="Copy" />
                            <telerik:EditorTool Name="Paste" ShortCut="CTRL+V" />
                            <telerik:EditorTool Name="PasteFromWordNoFontsNoSizes" />
                        </telerik:EditorToolGroup>
                        <telerik:EditorToolGroup Tag="Formatting">
                            <telerik:EditorTool Name="Bold" />
                            <telerik:EditorTool Name="Italic" />
                            <telerik:EditorTool Name="Underline" />
                            <telerik:EditorSeparator />
                            <telerik:EditorSplitButton Name="ForeColor" Width="80px">
                            </telerik:EditorSplitButton>
                            <telerik:EditorSplitButton Name="BackColor" Width="80px">
                            </telerik:EditorSplitButton>
                        </telerik:EditorToolGroup>
                    </Tools>
                    <Content>
                    </Content>
                </telerik:RadEditor>

With or without a stylesheet, it doesn't mather

In screen2 the dropdown arrows are at the wrong place

What can I do to correct it?

Regards,

Marco
Rumen Jekov
Top achievements
Rank 1
 answered on 08 Jan 2011
1 answer
155 views
I have a bound RadGrid which has three columns that are aggregated (Aggregate="Avg") on it. These three columns are of type currency. My challenge here is that the aggregation needs to be conditional based upon the value in the cell. If the value is $0.00, then it should not be included in the Average calculation. I know this seems odd, but it's the request that my users are giving to me.

Take the following example of the data in a segment of the grid

Sale Amount
$45.00
$50.00
$100.00
$0.00
-----------
Avg $48.75

The average calculation will be the sum of fields divided by the row count or (45 + 50 + 100 + 0) / 4 = 48.75

HOWEVER

What my users want is for this calculation to be (45 + 50 + 100 + 0) / 3 = 65  They want the row with $0.00 to not be included in the average calculation.

The documentation for the Aggregate (http://www.telerik.com/help/aspnet-ajax/grdtotalsingridfooters.html) has a little tidbit on the first page which *might* be what I'm looking for, but I'm not sure if it is or how to use it:

" RadGrid will calculate aggregates over the entire data source and will respect the filter expression applied (if present)"

Any assistance is very much appreciated!


Thank you,
Michael Smith

Mike Nogen
Top achievements
Rank 1
 answered on 08 Jan 2011
1 answer
128 views
hi
please see the attached file
how can i make this picture with treeview?
thanks a lot
niloofar
Top achievements
Rank 1
 answered on 08 Jan 2011
1 answer
71 views
I am using the RadGrid in a page - but for some reason it displays without any skin / styling. The grid is in a usercontrol - and I have a RadFormDecorator declared in the main page.

Here is the code I am using to display the grid:
<telerik:RadGrid ID="AddUserGrid" AutoGenerateColumns="false" ShowFooter="true" Width="400px" runat="server">
 <PagerStyle Mode="NextPrevAndNumeric" />
 <MasterTableView AutoGenerateColumns="false" TableLayout="Auto" ShowFooter="true">
     <Columns>
         <telerik:GridBoundColumn DataField="email" HeaderText="Email" />
         <telerik:GridBoundColumn DataField="username" HeaderText="UserName" />
                                 
     </Columns>
 </MasterTableView>
 <ClientSettings>
     <Selecting AllowRowSelect="true" />
 </ClientSettings>
 
 </telerik:RadGrid>

And here is how it looks:
Rendered Grid

Any idea on why all the style would be missing?
Christopher
Top achievements
Rank 1
 answered on 07 Jan 2011
9 answers
384 views
I am trying to do the tutorial located at:http://www.telerik.com/help/aspnet-ajax/grddesigncreatinghierarchicalgrids.html that a telerik staffer recommended I complete.  The problem is (as always) I can not find all the components to even learn the tutorial, namely, the ACCESS database file called Nwind.mdb.  I looked in the Live Demos/App_Data file (C:\Program Files\Telerik\RadControls for ASPNET AJAX Q3 2008\Live Demos\App_Data) and there is no Nwind.mdb file residing there.  I performed a search on my box and found this particular ACCESS database within another application (Developer Express .net), but nothing in the Live Demos/App_Data folder as the tutorial instructs, only Northwind.mdf and the Northwind.ldf. 

Now because I needed the .MDB file, not a .MDF file, I copied and pasted the Nwind.mdb file from the Developer Express folder and pasted it in the Live Demos/App_Data folder in Telerik.  I then copied said database file from the Dev Express directory and pasted it from that directory into the Live Demos/App_Data file of my telerik project as the tutorial instructs.  However, when I try to configure the database to the AccessDataSource1 control for the RadGrid to display the data, I keep receiving the following error:

  • Database schema could not be retrieved for this connection.  Please make sure the connections settings are correct and that the databse i online.  Unspecified error

Why can't I connect to the database?  I'm online, which I don't know how that makes any difference since the Live Demos/App_data directory is on hard drive.
 

Dan
Top achievements
Rank 2
 answered on 07 Jan 2011
0 answers
145 views
I have a RadGrid that is using a FormTemplate when inserting/updating values.

One of the values in my SQL Table is a bit flag. That is, it's going to be either true or false.

I can easily set this bit using a checkbox like the following in my FormTemplate:

<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("CanBeFatal") != DBNull.Value ? Convert.ToBoolean(Eval("CanBeFatal")) : false %>' />

This essentially selects the checkbox if the flag is set to true. However, I would prefer to display a RadComboBox instead of a checkbox and set the selected item based on the value of the bit flag. I've tried various methods to achieve this, but haven't had any success. I'm not sure if this is even possible, but any help would be appreciated.

Based on the sample below, if my bit flag is set to false, I would like the RadComboBox to have the 2nd item selected. For simplity of this message, I am leaving out the various methods I used to evaluate the bit flag and attempt to set the selection in the sample to avoid confusion.

<telerik:RadComboBox ID="RadComboBox2" runat="server" >
    <Items>
        <telerik:RadComboBoxItem Text="Yes" Value="true" />
        <telerik:RadComboBoxItem Text="No" Value="false" />
    </Items>
</telerik:RadComboBox>

Thanks!

UPDATE:
I was finally able to set the selection after playing a bit more. Seems the value for the bit is case sensitive. I got it working by doing the following:

<telerik:RadComboBox ID="RadComboBox2" runat="server" SelectedValue='<%# Eval("CanBeFatal") %>'>
    <Items>
        <telerik:RadComboBoxItem Text="Yes" Value="True" />
        <telerik:RadComboBoxItem Text="No" Value="False" />
    </Items>
</telerik:RadComboBox>

Guess I spoke to soon. Hope this helps someone else!
Paul
Top achievements
Rank 1
 asked on 07 Jan 2011
1 answer
289 views
Hello in my grid i hv one button inside the grid ..

<telerik:GridTemplateColumn DataField="DelFlag" HeaderText="Status" SortExpression="DelFlag"
                            HeaderStyle-HorizontalAlign="Center" UniqueName="DelFlag" Visible="true" AllowFiltering="false">
                            <ItemTemplate>
                               <asp:Button ID="btnStatus" Font-Size="11px" Width="65px" runat="server" Text='<%#Eval("DelFlag")%>'
                                 CommandName="Command" />                                
                            </ItemTemplate>
                            <ItemStyle VerticalAlign="Middle" HorizontalAlign="Center" />
                        </telerik:GridTemplateColumn>

if user click on button want to show the message "Are you sure want's to change status?". if user click yes then update status otherwise not.

 Please find attached image file u get an idea.   In image file Status column that button .. on click on that button want to show the confirmation message.



thanks
Mike Nogen
Top achievements
Rank 1
 answered on 07 Jan 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
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?