Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
302 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
153 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
91 views
How to give header to grid expand column.
Shinu
Top achievements
Rank 2
 answered on 07 Dec 2012
8 answers
519 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
81 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
640 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
78 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
117 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
1 answer
153 views
Hi people,
in the demo of TreeList it is written that "Its hybrid structure empowers you with the ability to visualize self-referencing data in a hierarchical view defining primary/foreign key relations and using identical objects for source."
I want to know if this control support non-self referencing data? Like

Code                 Chapter                Subchapter
----------------------------------------------------------
123456                12                          1234
456789                45                          4567
345678                34                          3456
124389                12                          1243

Here Chapter is the parent of subchapter.

12
     -1234
     -1243
45
     - 4567
34
    - 3456

Tell me can this control work for me?
Antonio Stoilkov
Telerik team
 answered on 07 Dec 2012
1 answer
183 views
Hi,

I have successfully deployed a test Silverlight application to SharePoint Online, which includes my trial Telerik controls. Specifically ChartView.

We do not however wish to develop future apps in Silverlight, for cross-browser/device compatibility reasons.

Am I able to use the ASP.Net versions of the same controls to develop ASP.Net applications or Webparts in SharePoint Online?

Note: SharePoint Online, not On-Premises.

Thanks,

Jason.
Stanimir
Telerik team
 answered on 07 Dec 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?