Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
68 views
Hi ,

I have report page with rad controls,  the rad combo box has a compare validator . There is a clear button. If you do not select any thing in the combo box, the compare validator throws an error message but on clicking of clear button h message does not get cleared, it is clearing only after the second click on clear button. I have tried giving auto post back true for clear button but it did not cause any difference. Also if i remove the validator then all other messages get cleared on the very first click.

Please Help. Thanks in Advance
Cat Cheshire
Top achievements
Rank 1
 answered on 07 Dec 2012
9 answers
153 views
How can I set the current page index on client side.  I have used all of the below and none of them seem to change the index.

ClientEvents-OnDataBound

 

ClientEvents-OnDataBinding
ClientEvents-OnGridCreated
ClientEvents-OnGridCreating
ClientEvents-OnMasterTableViewCreated
ClientEvents-OnMasterTableViewCreating

 

 

 

Also, here is my code below:

function
rgSchoolMonitor_OnDataBinding()

 

{

 

var grid = $find("<%=rgSchoolMonitor.ClientID %>");

 

 

var masterTableView = grid.get_masterTableView();

 

 

 

var pageCount = masterTableView.get_pageCount();

 

 

if (pageCount > 1)

 

{

 

//Need to Iterate Through Pages

 

 

var pageIndex = masterTableView.get_currentPageIndex();

 

 

 

if ((pageIndex + 1) > (pageCount - 1))

 

{

masterTableView.set_currentPageIndex(0);

}

 

else

 

{

masterTableView.set_currentPageIndex((pageIndex + 1));

}

 

 

}

 

}


Thanks,
Nick
Eyup
Telerik team
 answered on 07 Dec 2012
3 answers
268 views
Hi,

I am liking this new control, but I have one challenge.
My data has a variable number of columns returned.
I would like to set the column widths (beyond the 1st one) to a fixed size.
However, the column widths appear to be adjusted to fill up the available space.

Any thoughts?

Jim

<telerik:RadPivotGrid ID="grdRACI" runat="server" AllowFiltering="False" DataSourceID="sqlRACI" ClientSettings-Scrolling-AllowVerticalScroll="false"
                        TotalsSettings-GrandTotalsVisibility="None" Skin="Vista" AggregatesLevel="-1" ColumnHeaderCellStyle-Width="100px" RowHeaderCellStyle-Width="400px"
                        AggregatesPosition="Columns" OnCellDataBound="grdRACI_CellDataBound" IsFilterCommandInProgress="False" DataCellStyle-Width="100px" RowHeaderTableLayout="Fixed" ColumnHeaderTableLayout="Fixed"
                        ShowColumnHeaderZone="False" ShowDataHeaderZone="False" ShowFilterHeaderZone="False">
                        <Fields>
                            <telerik:PivotGridRowField DataField="Task" UniqueName="column">
                            </telerik:PivotGridRowField>
                            <telerik:PivotGridColumnField DataField="RoleName" UniqueName="column1">
                            </telerik:PivotGridColumnField>
                            <telerik:PivotGridAggregateField DataField="RACI" Aggregate="Max" GrandTotalAggregateFormatString=""
                                UniqueName="column2">
                            </telerik:PivotGridAggregateField>
                        </Fields>
                        <TotalsSettings GrandTotalsVisibility="None" />
                        <ConfigurationPanelSettings Position="FieldsWindow" />
                    </telerik:RadPivotGrid>
 
    protected void grdRACI_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e)
    {
        if (e.Cell is PivotGridColumnHeaderCell)
        {
            PivotGridColumnHeaderCell cell = e.Cell as PivotGridColumnHeaderCell;
            cell.HorizontalAlign = HorizontalAlign.Center;
            cell.Wrap = true;
        }
 
        if (e.Cell is PivotGridDataCell)
        {
            Color CFFD_Highlight = Color.Beige;
 
            PivotGridDataCell dataCell = e.Cell as PivotGridDataCell;
            if (dataCell != null)
            {
                switch (dataCell.Text)
                {
                    case ("1"):
                        dataCell.Text = "R";
                        break;
                    case ("2"):
                        dataCell.Text = "A";
                        break;
                    case ("3"):
                        dataCell.Text = "C";
                        break;
                    case ("4"):
                        dataCell.Text = "I";
                        break;
                    case ("5"):
                        dataCell.Text = "R/A";
                        break;
                    case ("10"):
                        dataCell.Text = "R";
                        dataCell.BackColor = CFFD_Highlight;
                        break;
                    case ("20"):
                        dataCell.Text = "A";
                        dataCell.BackColor = CFFD_Highlight;
                        break;
                    case ("30"):
                        dataCell.Text = "C";
                        dataCell.BackColor = CFFD_Highlight;
                        break;
                    case ("40"):
                        dataCell.Text = "I";
                        dataCell.BackColor = CFFD_Highlight;
                        break;
                    case ("50"):
                        dataCell.Text = "R/A";
                        dataCell.BackColor = CFFD_Highlight;
                        break;
                }
                dataCell.HorizontalAlign = HorizontalAlign.Center;
            }
        }
    }
Antonio Stoilkov
Telerik team
 answered on 07 Dec 2012
1 answer
112 views
How to hide previous and first page arrow buttons on page 1and nextand last page arrows
On last page
Princy
Top achievements
Rank 2
 answered on 07 Dec 2012
1 answer
55 views
How to give header to grid expand column.
Shinu
Top achievements
Rank 2
 answered on 07 Dec 2012
8 answers
465 views
I have a RadBinaryImage control which is displaying an image loaded using RadAsyncUpload.

I have an SQL table containing a 'Photo' column (image data type). How to pass the RadBinaryImage to the insert function which look like this:

Private Sub InsertPhotoIntoDB()
        Dim sMyConn As String = My.Settings.appDBConnString
        Dim myConnection As SqlConnection
        Dim myCommand As New SqlCommand
        myConnection = New SqlConnection(sMyConn)
 
        myConnection.Open()
 
        myCommand = New SqlCommand("INSERT INTO Photos(Photo) VALUES(@Photo)")
        myCommand.Connection = myConnection
 
        myCommand.Parameters.Add("@Photo", SqlDbType.Image, 0, "Photo")
        myCommand.Parameters("@Photo").Value = WhatDoIPutHere???
 
        myCommand.ExecuteNonQuery()
 
        myConnection.Close()
        myConnection.Dispose()
End Sub
Emil
Top achievements
Rank 2
 answered on 07 Dec 2012
1 answer
66 views
We are using a WCF service to databind our grid client-side. Certain rows need to be a different color based on the data returned from the service.

At first, I attempted using a GridTemplateColumn to bind with a <div class='<%# Eval("ClassName") %>'><%# Eval("Title") %></div> to swap colors, but quickly realized that the DataBinder is a server-side capability.

Is there a way to either a) do a client-side template column with databinding or b) handle the javascript OnDataItemBound?

Christopher
Antonio Stoilkov
Telerik team
 answered on 07 Dec 2012
4 answers
598 views
I am enhancing a search feature on our site and am using jQuery in conjunction with the client-side api for the RadGrid. My problem is that itemdatabound, as well as any methods that are invoked from gridtemplatecolumns in the grid are all fired BEFORE the grid is databound, which obviously causes problems. I could almost live with it if when i finally invoke databind() the methods are called again, but they are not.

I put together a quick example of what I am talking about... please make sure if you try and recreate this problem that you reference the newest version of jquery in the head of the doc.
ASPX Page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxExample.aspx.cs" Inherits="WolperWeb.company.AjaxExample" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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>
    <script type="text/javascript" language="javascript" src="../scripts/jquery-1.4.1.js"></script>
    <telerik:RadCodeBlock ID="rcbJavaScript" runat="server">
    <script type="text/javascript">
        $(function () {
            ////////////////////////////////////////////////////////////////////////////////////////////////////////
            /// TEST CODE /////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////
            /// REQURIED PARAMETERS : int WebID, int AccountID, string SearchTerm, int CurrentPage, int PageSize
            /////////////////////////////////////////////////////////////////////////////////////////////////////
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                url: "ajaxexample.aspx/GetData",
                data: "{ }",
                success: function (result) {
                    var publications = (typeof result.d) == 'string' ? eval('(' + result.d + ')') : result.d;
                    for (var key in publications) {
                        if (key == "book") {
                            tableView.set_dataSource(publications[key]);
                            tableView.dataBind();
                        }
                    }
 
                },
                error: function (xhr, ajaxOptions) {
                    alert("error: " + xhr.responseText);
                }
            });
        });
 
        var tableView;
        function pageLoad(sender, args) {
            tableView = $find("<%= rgPublicationResults.ClientID %>").get_masterTableView();
        }
 
 
        function rgPublicationResults_Command(sender, args) { }
    </script>
</telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
<telerik:RadGrid ID="rgPublicationResults" runat="server" Skin="Simple" OnItemDataBound="rgPublicationResults_ItemDataBound">
    <ClientSettings AllowColumnsReorder="true">
        <ClientEvents OnCommand="rgPublicationResults_Command" />
    </ClientSettings>
    <MasterTableView GridLines="None" AutoGenerateColumns="false">
        <Columns>
            <telerik:GridBoundColumn DataField="BookName" HeaderText="Title" UniqueName="BookName" />
            <telerik:GridBoundColumn DataField="Term" HeaderText="Term" UniqueName="Author" />
            <telerik:GridBoundColumn DataField="BookID" HeaderText="ID" UniqueName="BookID" />
            <telerik:GridTemplateColumn HeaderText="Price" UniqueName="Price">
                <ItemTemplate>
                    <%# GetPrice(Eval("Price")) %>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="TestField" UniqueName="TestField">
                <ItemTemplate>
                    <asp:Label ID="lblTest" runat="server" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
        <AlternatingItemStyle VerticalAlign="Top" />
        <ItemStyle VerticalAlign="Top" />
    </MasterTableView>
</telerik:RadGrid>
    </form>
</body>
</html>

Codebehind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using Telerik.Web.UI;
 
namespace WolperWeb.company
{
    public partial class AjaxExample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected string GetPrice(object Price)
        {
            try
            {
                return String.Format("Order Total: {0:C}", Price);
            }
            catch { return "failed"; }
        }
 
        protected void rgPublicationResults_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item)
            {
                Label lblTest = (Label)e.Item.FindControl("lblTest");
                lblTest.Text = "test";
            }
 
        }
 
        [WebMethod]
        public static Dictionary<string, object> GetData()
        {
            Dictionary<string, object> result = new Dictionary<string, object>();
            List<BookData> lBooks = new List<BookData>();
 
            BookData oBook = new BookData();
            oBook.Author = "John Smith";
            oBook.BookID = "bk101";
            oBook.BookName = "Book Number 1";
            oBook.Price = 10;
 
            lBooks.Add(oBook);
 
            oBook = new BookData();
            oBook.Author = "Bill Smith";
            oBook.BookID = "bk102";
            oBook.BookName = "Book Number 2";
            oBook.Price = 15;
 
            lBooks.Add(oBook);
 
            oBook = new BookData();
            oBook.Author = "Rob Smith";
            oBook.BookID = "bk103";
            oBook.BookName = "Book Number 3";
            oBook.Price = 20;
 
            lBooks.Add(oBook);
 
            oBook = new BookData();
            oBook.Author = "Jane Smith";
            oBook.BookID = "bk104";
            oBook.BookName = "Book Number 4";
            oBook.Price = 25;
 
            lBooks.Add(oBook);
 
            result.Add("book", lBooks);
            return result;
        }
    }
 
    public struct BookData
    {
        public string BookName { get; set; }
        public string BookID { get; set; }
        public string Author { get; set; }
        public decimal Price { get; set; }
    }
}

Also, I think it's worth mentioning that this line of code kept returning null until i defined an empty client side oncommand event, as you will see in the code. If that is a known issue, it should be better documented as I also spent a good amount of time trying to figure out why I couldn't grab a reference to the grid:
var tableView;
function pageLoad(sender, args) {
    tableView = $find("<%= rgPublicationResults.ClientID %>").get_masterTableView();
}
Antonio Stoilkov
Telerik team
 answered on 07 Dec 2012
1 answer
62 views
Hi,
I am trying to do a soft save of the grid items to  a datatable, when add new item is clicked.

Currently i am using the hashtable to store the data. However, i would like to add those items to datatable.

GridEditableItem item = e.Item as GridEditableItem;
          Hashtable values = new Hashtable();
          DataTable dt = new DataTable();            
          item.ExtractValues(values);

How to add the values to the datatable?
Thanks
Antonio Stoilkov
Telerik team
 answered on 07 Dec 2012
3 answers
97 views
Hi, I'm using the RadToolBar in the CommandItemTemplate of the RadGrid.
I've adjusted the width of the grid to 100%.
I need to display to the user 12+ independent RadToolBarButton and in some of them I have big text to explain to the user what the action is. The result is that the last buttons are not totally or partially visible. Is there any property in the toolbar or an adjustment possible to be made? maybe a scroll or a '...'  or ' >>>' button to view the mentioned buttons?
Thanks, Ariel.
Kate
Telerik team
 answered on 07 Dec 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?