Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
207 views
I have a radgrid with a checkbox column and textbox column as follows:

           this._RadGrid1.AllowFilteringByColumn = true;
            this._RadGrid1.AllowSorting = true;           
            this._RadGrid1.MasterTableView.AllowNaturalSort = true;          
            
            this._RadGrid1.MasterTableView.DataKeyNames = new string[] { this._PriceDealProductBanTable.PriceDealEntityProductItemIdColumn.ColumnName };
            this._RadGrid1.MasterTableView.ClientDataKeyNames = new string[] { this._PriceDealProductBanTable.PriceDealEntityProductItemIdColumn.ColumnName };                                            
            this._RadGrid1.EnableLinqExpressions = false;         
 
            this._RadGrid1.MasterTableView.NoMasterRecordsText = "No Products found.";
            this._RadGrid1.MasterTableView.Width = Unit.Percentage(100);
             
            this._RadGrid1.ClientSettings.Selecting.AllowRowSelect = true;
            this._RadGrid1.AllowMultiRowSelection = true;
             
             
            this._RadGrid1.NeedDataSource += RadGrid1_NeedDataSource;
            this._RadGrid1.ItemDataBound += RadGrid1_ItemDataBound;
 
            GridBoundColumn boundColumn = new GridBoundColumn();
            string columnName;
            
            #region RadGrid Columns
            GridClientSelectColumn selectAll = new GridClientSelectColumn();
            selectAll.UniqueName = "SelectOne";
            this._RadGrid1.MasterTableView.Columns.Add(selectAll);
//Other columns
            templateColumn = new GridTemplateColumn();
            templateColumnName = this._PriceDealProductBanTable.BillingAccountNumberColumn.ColumnName;
            this._RadGrid1.MasterTableView.Columns.Add(templateColumn);
            templateColumn.DataField = templateColumnName;
            templateColumn.ItemTemplate = new TextBoxTemplate(templateColumnName);
            templateColumn.HeaderText = "BAN";
            templateColumn.UniqueName = "BAN";           
            templateColumn.AllowFiltering = false;           

The textboxtemplate is as follows:
public class TextBoxTemplate : ITemplate
    {
        protected RadTextBox _textBox;
        string _columnName;
        public TextBoxTemplate(string columnName)
        {
            this._columnName = columnName;
        }
        public void InstantiateIn(System.Web.UI.Control container)
        {
 
            this._textBox = new RadTextBox();
            this._textBox.ID = this._columnName;
            container.Controls.Add(this._textBox);
            this._textBox.DataBinding += new EventHandler(_textBox_DataBinding);
        }
        void _textBox_DataBinding(object sender, EventArgs e)
        {
            RadTextBox txt = (RadTextBox)sender;
            GridDataItem container = (GridDataItem)txt.NamingContainer;
            txt.Text = ((DataRowView)container.DataItem)[this._columnName].ToString();
        }
    }

When I click on the textbox, I want the row to be automatically selected. How can I achieve this?
Also after selections are made, and i click on a row, all selections are disabled. I want to change this behaviour also. Deselect only happens when I click on the checkbox.
Shinu
Top achievements
Rank 2
 answered on 09 Jul 2014
1 answer
176 views
I have a RadGrid as follows:

this._RadGrid1.AllowSorting = true;           
 this._RadGrid1.MasterTableView.AllowNaturalSort = true;          
 
 this._RadGrid1.MasterTableView.DataKeyNames = new string[] { this._PriceDealProductBanTable.PriceDealEntityProductItemIdColumn.ColumnName };
 this._RadGrid1.MasterTableView.ClientDataKeyNames = new string[] { this._PriceDealProductBanTable.PriceDealEntityProductItemIdColumn.ColumnName };                                            
 this._RadGrid1.EnableLinqExpressions = false;         
 
 this._RadGrid1.MasterTableView.NoMasterRecordsText = "No Products found.";
 this._RadGrid1.MasterTableView.Width = Unit.Percentage(100);
  
 this._RadGrid1.ClientSettings.Selecting.AllowRowSelect = true;
 this._RadGrid1.AllowMultiRowSelection = true;
  
  
 this._RadGrid1.NeedDataSource += RadGrid1_NeedDataSource;
 this._RadGrid1.ItemDataBound += RadGrid1_ItemDataBound;
 
 GridBoundColumn boundColumn = new GridBoundColumn();
 string columnName;
 
 #region RadGrid Columns
 GridClientSelectColumn selectAll = new GridClientSelectColumn();
 selectAll.UniqueName = "SelectOne";
 this._RadGrid1.MasterTableView.Columns.Add(selectAll);

the GridClientSelectColumn allows multiple selection, but clicking on a row de-selects all other rows.  I want the all rows to stay selected unless manually de-selected from the checkbox. How can I achieve this?
Princy
Top achievements
Rank 2
 answered on 09 Jul 2014
4 answers
173 views
I put the following code in the RadGrid1_PageIndexChanged event:

if ((e.NewPageIndex + 1) == rgResults.PageCount)
{
    showingRowsTo = GridSource.Tables[0].Rows.Count;
}
else
{
    showingRowsTo = (e.NewPageIndex + 1) * rgResults.PageSize;
}
  
string rowCount = string.Format("Displaying {0}-{1} of {2}", showingRowsFrom, showingRowsTo, GridSource.Tables[0].Rows.Count);
lblResultsCountBottom.Text = lblResultsCountTop.Text = rowCount;


Unfortunately, it looks like this doesn't do a full postback and the label doesn't end up getting updated. How can I go about doing this? I tried doing it client side and had problems with this, too. It says $find is undefined.

$(document).ready(function () {
    var grid = $find("<%=rgResults.ClientID%>");
    var mtv = grid.get_masterTableView();
    var pageIndex = mtv.get_currentPageIndex();
    alert(pageIndex);
});
Jesse
Top achievements
Rank 1
 answered on 08 Jul 2014
2 answers
288 views
Hi,

Can you please provide some suggestion on creating a chart on server side and export SVG out of it to create vector graphics/pdf.

We have an application which runs as a scheduler on the server, generates charts and emails them to customers in PDF/Images. All this without any manual interaction.

I looked at RadChart and RadHTMLChart. RadChart is a server side compontent but can't export vercor graphics, and RadHtmlChart renders SVG strictly the on browser.

The problem with using RadHtmlChart is we have to run a browser object from server side code to execute JS which can be a 'not so' reliable solution.

Please suggest. Thanks!
Raghu
Top achievements
Rank 1
 answered on 08 Jul 2014
11 answers
593 views
Hi,

I would like to use the RadGrid in an ASP.net web page using the DynamicDataManager.  I have tried just registering the RadGrid with the DynamicDataManager but get errors saying that the control is not supported (I know I was being hopeful !).  I then did some digging around and found the class for DynamicRadGrid. This example was in C# but I converted it to the following:~

Imports System 
Imports System.Data 
Imports System.Configuration 
Imports System.Linq 
Imports System.Web 
Imports System.Web.Security 
Imports System.Web.UI 
Imports System.Web.UI.HtmlControls 
Imports System.Web.UI.WebControls 
Imports System.Web.UI.WebControls.WebParts 
Imports System.Xml.Linq 
Imports Telerik.Web.UI 
Imports System.Collections 
Imports System.Web.DynamicData 
Imports System.Collections.Generic 
Imports System.ComponentModel 
Imports System.Globalization 
Imports System.Collections.Specialized 
 
<ControlValueProperty("DataKeySelectedValue")> _ 
Public Class DynamicRadGrid 
    Inherits RadGrid 
    Implements IControlParameterTarget 
    Implements IPersistedSelector 
    ' 
    Public Sub New() 
    End Sub 
 
    Private selectedIndex As String = Nothing 
 
    Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs) 
        If SelectedIndexes.Count > 0 Then 
            selectedIndex = SelectedIndexes(0) 
        End If 
 
        MyBase.OnLoad(e) 
    End Sub 
 
    Protected Overloads Overrides Sub OnDataBound(ByVal e As EventArgs) 
        MyBase.OnDataBound(e) 
 
        If selectedIndex <> Nothing Then 
            Dim item As GridItem = Items(selectedIndex) 
            If Not item Is Nothing Then 
                item.Selected = True 
            End If 
        Else 
            If Items.Count > 0 Then 
                Items(0).Selected = True 
            End If 
        End If 
    End Sub 
 
    <Browsable(False)> _ 
    Public ReadOnly Property DataKeySelectedValue() As Object 
        Get 
            If Not Me.DataKey Is Nothing Then 
                Return Me.DataKey.Value 
            End If 
 
            Return SelectedValue 
        End Get 
    End Property 
 
    Private _dataKey As System.Web.UI.WebControls.DataKey 
    Public Property DataKey() As System.Web.UI.WebControls.DataKey Implements IPersistedSelector.DataKey 
        Get 
            Return _dataKey 
        End Get 
        Set(ByVal value As System.Web.UI.WebControls.DataKey) 
            _dataKey = value 
            If Not _dataKey Is Nothing Then 
                DirectCast(_dataKey, IStateManager).TrackViewState() 
            End If 
        End Set 
    End Property 
 
    'protected override object SaveControlState() 
    '{ 
    '    return new object[]{ 
    '        base.SaveControlState(), 
    '        _dataKey != null ? ((IStateManager)_dataKey).SaveViewState() : null 
    '    }; 
    '} 
 
    'protected override void LoadControlState(object savedState) 
    '{ 
    '    object[] controlState = (object[])savedState; 
    '    base.LoadControlState(controlState[0]); 
    '    if (_dataKey != null) 
    '    { 
    '        ((IStateManager)_dataKey).LoadViewState(controlState[1]); 
    '    } 
    '} 
 
    Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs) 
        MyBase.OnInit(e) 
 
        AllowAutomaticUpdates = True 
        AllowAutomaticDeletes = True 
 
        Dim metaTable As MetaTable = Me.FindMetaTable() 
 
        Dim list As New List(Of String)() 
        For Each column As MetaColumn In metaTable.PrimaryKeyColumns 
            list.Add(column.Name) 
        Next 
        MasterTableView.DataKeyNames = list.ToArray() 
 
        For Each column As MetaColumn In metaTable.Columns 
            If Not column.Scaffold OrElse column.IsLongString OrElse TypeOf column Is MetaChildrenColumn Then 
                Continue For 
            End If 
 
            Dim gridColumn As New DynamicGridBoundColumn() 
 
            gridColumn.DataField = column.Name 
            gridColumn.ConvertEmptyStringToNull = column.ConvertEmptyStringToNull 
            gridColumn.DataFormatString = column.DataFormatString 
            gridColumn.UIHint = column.UIHint 
            gridColumn.HtmlEncode = column.HtmlEncode 
            gridColumn.NullDisplayText = column.NullDisplayText 
            gridColumn.ApplyFormatInEditMode = column.ApplyFormatInEditMode 
            gridColumn.HeaderText = column.DisplayName 
 
            MasterTableView.Columns.Add(gridColumn) 
        Next 
    End Sub 
 
    Public Function GetPropertyNameExpression(ByVal columnName As StringAs String Implements IControlParameterTarget.GetPropertyNameExpression 
        Return "DataKeySelectedValue" 
    End Function 
 
    ReadOnly Property Table() As MetaTable Implements IControlParameterTarget.Table 
        Get 
            Return Me.FindMetaTable() 
        End Get 
    End Property 
 
    Public Overridable ReadOnly Property FilteredColumn() As MetaColumn Implements IControlParameterTarget.FilteredColumn 
        Get 
            Return Nothing 
        End Get 
    End Property 
End Class 
 
Public Class DynamicGridBoundColumn 
    Inherits GridBoundColumn 
    Private _applyFormatInEditMode As System.Nullable(Of Boolean
    Private _convertEmptyStringToNull As System.Nullable(Of Boolean
    Private _dataField As String 
    Private _dataFormatString As String 
    Private _htmlEncode As Boolean = True 
    Private _nullDisplayText As String 
    Private _column As MetaColumn 
 
    Public Overloads Overrides Sub FillValues(ByVal newValues As IDictionary, ByVal editableItem As GridEditableItem) 
        Dim values As New OrderedDictionary() 
 
        ExtractValuesFromBindableControls(values, editableItem) 
 
        For Each entry As DictionaryEntry In values 
            If Not newValues.Contains(entry.Key) Then 
                newValues.Add(entry.Key, entry.Value) 
            End If 
        Next 
    End Sub 
 
    Friend Shared Sub ExtractValuesFromBindableControls(ByVal dictionary As IOrderedDictionary, ByVal container As Control) 
        Dim control As IBindableControl = TryCast(container, IBindableControl) 
        If Not control Is Nothing Then 
            control.ExtractValues(dictionary) 
        End If 
        For Each control2 As Control In container.Controls 
            ExtractValuesFromBindableControls(dictionary, control2) 
        Next 
    End Sub 
 
    Public Overloads Overrides Sub InitializeCell(ByVal cell As TableCell, ByVal columnIndex As IntegerByVal inItem As GridItem) 
        If TypeOf inItem Is GridEditableItem Then 
            Dim dynamicControl As New DynamicControl() 
            dynamicControl.DataField = DataField 
 
            Dim isInsert As Boolean = TypeOf inItem Is GridEditFormInsertItem OrElse TypeOf inItem Is GridDataInsertItem 
 
            If isInsert Then 
                dynamicControl.Mode = DataBoundControlMode.Insert 
            End If 
 
            If inItem.IsInEditMode Then 
                dynamicControl.Mode = DataBoundControlMode.Edit 
            End If 
 
            dynamicControl.UIHint = UIHint 
            dynamicControl.HtmlEncode = HtmlEncode 
            dynamicControl.DataFormatString = DataFormatString 
            dynamicControl.NullDisplayText = NullDisplayText 
 
            If _convertEmptyStringToNull.HasValue Then 
                dynamicControl.ConvertEmptyStringToNull = ConvertEmptyStringToNull 
            End If 
 
            If _applyFormatInEditMode.HasValue Then 
                dynamicControl.ApplyFormatInEditMode = ApplyFormatInEditMode 
            End If 
 
            cell.Controls.Add(dynamicControl) 
        Else 
            MyBase.InitializeCell(cell, columnIndex, inItem) 
        End If 
    End Sub 
 
 
    <Category("Behavior"), DefaultValue(False)> _ 
    Public Overloads Property ConvertEmptyStringToNull() As Boolean 
        Get 
            If Me._convertEmptyStringToNull.HasValue Then 
                Return Me._convertEmptyStringToNull.Value 
            End If 
            Return False 
        End Get 
        Set(ByVal value As Boolean
            Me._convertEmptyStringToNull = New System.Nullable(Of Boolean)(value) 
        End Set 
    End Property 
 
    <DefaultValue(""), Category("Behavior")> _ 
    Public Overrides Property DataField() As String 
        Get 
            If Not Me._dataField Is Nothing Then 
                Return Me._dataField 
            End If 
            Dim obj2 As Object = MyBase.ViewState("DataField"
            If not obj2 is Nothing Then 
                Return DirectCast(obj2, String
            End If 
            Return String.Empty 
        End Get 
        Set(ByVal value As String
            If Not Object.Equals(value, MyBase.ViewState("DataField")) Then 
                MyBase.ViewState("DataField") = value 
                Me._dataField = value 
                Me.OnColumnChanged() 
            End If 
        End Set 
    End Property 
 
    <Category("Data"), DefaultValue("")> _ 
    Public Overrides Property DataFormatString() As String 
        Get 
            Return (If(Me._dataFormatString, String.Empty)) 
        End Get 
        Set(ByVal value As String
            Me._dataFormatString = value 
        End Set 
    End Property 
 
    Private ReadOnly Property Column() As MetaColumn 
        Get 
            If MyBase.DesignMode OrElse (Owner Is NothingThen 
                Return Nothing 
            End If 
            If Me._column Is Nothing Then 
                Dim table As MetaTable = Owner.OwnerGrid.FindMetaTable() 
                If table Is Nothing Then 
                    Throw New InvalidOperationException(""
                End If 
                Me._column = table.GetColumn(Me.DataField) 
            End If 
            Return Me._column 
        End Get 
    End Property 
 
    Public Overloads Overrides Property HeaderText() As String 
        Get 
            Dim obj2 As Object = MyBase.ViewState("HeaderText"
            If Not obj2 Is Nothing Then 
                Return DirectCast(obj2, String
            End If 
            If Not Me.Column Is Nothing Then 
                Return Me.Column.DisplayName 
            End If 
            Return Me.DataField 
        End Get 
        Set(ByVal value As String
            MyBase.HeaderText = value 
        End Set 
    End Property 
 
    <DefaultValue(True), Category("Behavior")> _ 
    Public Overrides Property HtmlEncode() As Boolean 
        Get 
            Return Me._htmlEncode 
        End Get 
        Set(ByVal value As Boolean
            Me._htmlEncode = value 
        End Set 
    End Property 
 
    <Category("Behavior"), DefaultValue("")> _ 
    Public Property NullDisplayText() As String 
        Get 
            Return (If(Me._nullDisplayText, String.Empty)) 
        End Get 
        Set(ByVal value As String
            Me._nullDisplayText = value 
        End Set 
    End Property 
 
 
    <DefaultValue(""), Category("Behavior")> _ 
    Public Overridable Property UIHint() As String 
        Get 
            Dim obj2 As Object = MyBase.ViewState("UIHint"
            If Not obj2 Is Nothing Then 
                Return DirectCast(obj2, String
            End If 
            Return String.Empty 
        End Get 
        Set(ByVal value As String
            If Not Object.Equals(value, MyBase.ViewState("UIHint")) Then 
                MyBase.ViewState("UIHint") = value 
                Me.OnColumnChanged() 
            End If 
        End Set 
    End Property 
 
    <Category("Behavior"), DefaultValue(False)> _ 
    Public Property ApplyFormatInEditMode() As Boolean 
        Get 
            If Me._applyFormatInEditMode.HasValue Then 
                Return Me._applyFormatInEditMode.Value 
            End If 
            Return False 
        End Get 
        Set(ByVal value As Boolean
            Me._applyFormatInEditMode = New System.Nullable(Of Boolean)(value) 
        End Set 
    End Property 
 
    Public Overloads Overrides Function Clone() As GridColumn 
        Dim column As New DynamicGridBoundColumn() 
        column.CopyBaseProperties(Me
 
        Return column 
    End Function 
 
    Protected Overloads Overrides Sub CopyBaseProperties(ByVal fromColumn As GridColumn) 
        MyBase.CopyBaseProperties(fromColumn) 
        Dim source As DynamicGridBoundColumn = DirectCast(fromColumn, DynamicGridBoundColumn) 
 
        ConvertEmptyStringToNull = source.ConvertEmptyStringToNull 
        DataFormatString = source.DataFormatString 
        UIHint = source.UIHint 
        HtmlEncode = source.HtmlEncode 
        NullDisplayText = source.NullDisplayText 
        ApplyFormatInEditMode = source.ApplyFormatInEditMode 
    End Sub 
 
End Class 
 
 


The control now registers but I get an error in the designer saying httpContext can not be null.  The project builds however, but when I run it the following code in the OnInit method throws an error (Me.FindMetaTable).    
 Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs) 
        MyBase.OnInit(e) 
 
        AllowAutomaticUpdates = True 
        AllowAutomaticDeletes = True 
 
        Dim metaTable As MetaTable = Me.FindMetaTable() 
 


Would it be possible to have a working VB.net version of this control for using with the DynamicDataManager?


Regards,

Mark
Erik
Top achievements
Rank 2
 answered on 08 Jul 2014
2 answers
296 views
I am using RadGrids in my webpage in several places. I want to customize the "insert" text when adding a new record.

Using the build in command item button to add a new record, it provides the fields to fill in along with an "insert" and "cancel" link. I want to change the text of the "insert" link to something else.

How can this be done?
Gary
Top achievements
Rank 1
 answered on 08 Jul 2014
1 answer
171 views
Hi!

I'm very interested in your Diagram solution and I work at a SharePoint integrated Solution at the moment. I'm wondering if there is a possibilty to import Data from Visio or other datasources already?

Thank you for your help!
Pascal
Vessy
Telerik team
 answered on 08 Jul 2014
13 answers
569 views
I wish to export the content in a RadGrid to excel/pdf format by setting the header and footer for each and every page. Is there any ways to accomplish that.

- I know that there is a pageTitle property for pdf export, but Is there a way to include formatted headers than title for the grid data.
   (ie:- I would include date/time, pagenumber, company/author name, copyrights message.

Thanks,
Vijayaraj
Daniel
Telerik team
 answered on 08 Jul 2014
1 answer
143 views
I have a local intranet web application for which users need to log in.  The app features a radGrid for which the user can change multiple settings.  I would like for the user to be able to customize the grid so that the next time they log in, it would remember:

Columns visible / invisible
Columns widths
Column order
Sort orders
Filters applied

I found this article but it's only for a session, not subsequent sessions.  At the bottom of the article there is a dead link for what I want to do....



Kostadin
Telerik team
 answered on 08 Jul 2014
1 answer
159 views
Hai All,

i have one raddatepicker for this i set max date some thing 7/7/2014 here for me everything is working fine but when i am selecting 7/7/2014 it is showing in error how to fix
Shinu
Top achievements
Rank 2
 answered on 08 Jul 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?