Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
123 views
I binded data to radgrid using webservice but GridEditCommandColumn & GridButtonColumn  click event  not fire

 
<telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True" AllowSorting="True"
    AutoGenerateColumns="False" GridLines="None"
    OnItemCommand="RadGrid1_ItemCommand">
    <MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id">
        <Columns>
            <telerik:GridBoundColumn DataField="Firstname" HeaderText="Firstname" DataType="System.String">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Lastname" HeaderText="Lastname" DataType="System.String">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Age" HeaderText="Age" DataType="System.Int32">
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"
                ButtonType="ImageButton">
            </telerik:GridButtonColumn>
        </Columns>
        <PagerStyle Mode="Slider" />
    </MasterTableView>
    <ClientSettings>
        <DataBinding SelectMethod="GetSampleData" Location="Webservice/GridData.svc" SortParameterType="String">
        </DataBinding>
    </ClientSettings>
</telerik:RadGrid>

However when clicking on the appropriate button on a grid row the event isn't fired, basically no postback to the server is being done. A solution I found is to add the "EnablePostBackOnRowClick=true" to the ClientSettings, but this would cause a postback on each click on a row, which is not really desired.

Is there a better way to realizing this or does anybody have a hint what could be the problem??

nanthakumar thangavel
Top achievements
Rank 1
 answered on 17 Aug 2010
6 answers
538 views
Quick question.  I see you can change the colors and fonts in RadGrid using VSB, but how do you change just pagination buttons at the bottom?  I just want to do a simple color change so the page buttons match the button colors on my site.  Also, is there anything you can do other than get in the code when VSB won't accept CSS changes?  I've tried to change the header font several times and it just won't accept it.  Thanks in advance!
Dimo
Telerik team
 answered on 17 Aug 2010
1 answer
69 views
Hello, I have a Rad Dock and I am saving the layout into a database, I am saving whenever I move a dock item. The problem is if I move a dock item around too much, or move an item erratically the item duplicates. I attached the html and vb.net can anyone help me with this problem?

VB.net
Imports System.Web.Script.Serialization

Partial Class MyLanding
    Inherits System.Web.UI.Page
    Private LoginClass As New LoginClass
    Private _dockStateCleared As Boolean = False
    Private _conn As New SqlConnection(ConfigurationManager.ConnectionStrings("MidwestPartsConnectionString").ConnectionString)

    Private ReadOnly Property CurrentDockStates() As List(Of DockState)
        Get
            'Get saved state string from the database - set it to dockState variable for example
            Dim dockStatesFromDB As String = ""

            _conn.Open()
            Dim command As New SqlCommand("SELECT JavascriptStr FROM SysProperties WHERE (UserID = @UserID)", _conn)
            command.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier).Value = Me.LoginClass.ReturnUserID()
            Try
                dockStatesFromDB = command.ExecuteScalar().ToString()
                _conn.Close()
            Catch ex As Exception
                _conn.Close()
                Me.CreateSavedLayout("")
            End Try

            Dim _currentDockStates As New List(Of DockState)()
            Dim stringStates As String() = dockStatesFromDB.Split("|"c)
            For Each stringState As String In stringStates
                If stringState.Trim() <> String.Empty Then
                    _currentDockStates.Add(DockState.Deserialize(stringState))
                End If
            Next
            Return _currentDockStates
        End Get
    End Property


    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        If Not Page.IsPostBack Then
            If CurrentDockStates.Count = 0 Then
                Me.LoadItems()
            End If
        End If
    End Sub

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
        Dim i As Integer = 0
        While i < CurrentDockStates.Count
            If CurrentDockStates(i).Closed = False Then
                Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i))
                dlColumnOne.Controls.Add(dock)
                CreateSaveStateTrigger(dock)
                LoadUserControl(dock)
            End If
            System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
        End While
    End Sub

    Protected Sub dlColumnOne_LoadDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)
        For Each state As DockState In CurrentDockStates
            e.Positions(state.UniqueName) = state.DockZoneID
            e.Indices(state.UniqueName) = state.Index
        Next
    End Sub
    Protected Sub dlColumnOne_SaveDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)
        Dim stateList As List(Of DockState) = dlColumnOne.GetRegisteredDocksState()
        Dim serializedList As New StringBuilder()
        Dim i As Integer = 0

        While i < stateList.Count
            serializedList.Append(stateList(i).ToString())
            serializedList.Append("|")
            System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
        End While

        Dim dockState As String = serializedList.ToString()
        If dockState.Trim() <> [String].Empty Then
            _conn.Open()
            Dim command As New SqlCommand([String].Format("update sysproperties set javascriptstr = '{0}' Where UserID = @UserID ", dockState), _conn)
            command.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier).Value = Me.LoginClass.ReturnUserID()
            command.ExecuteNonQuery()
            _conn.Close()
        End If
    End Sub

    Private Function CreateRadDockFromState(ByVal state As DockState) As RadDock
        Dim dock As New RadDock()
        dock.DockMode = DockMode.Docked
        dock.UniqueName = state.UniqueName
        dock.ID = String.Format("RadDock{0}", dock.UniqueName)
        dock.ApplyState(state)
        dock.Commands.Add(New DockCloseCommand())
        dock.Commands.Add(New DockExpandCollapseCommand())
        Return dock
    End Function

    Private Function CreateRadDock(ByVal DockTitle As String) As RadDock
        Dim docksCount As Integer = CurrentDockStates.Count
        Dim dock As New RadDock
        dock.DockMode = DockMode.Docked
        Dim UniqueName As String = Guid.NewGuid().ToString()
        UniqueName = UniqueName.Replace("-", "")
        dock.UniqueName = UniqueName
        dock.ID = String.Format("RadDock{0}", UniqueName)
        dock.Title = DockTitle
        dock.Width = Unit.Pixel(400)
        dock.Commands.Add(New DockCloseCommand())
        dock.Commands.Add(New DockExpandCollapseCommand())
        Return dock
    End Function

    Private Sub LoadItems()
        Dim DocksDataTable As DataTable = Me.ReturnReports()
        For i = 0 To DocksDataTable.Rows.Count() - 1
            Dim dock As RadDock = Me.CreateRadDock(DocksDataTable.Rows(i).Item("ReportTitle").ToString())
            Dim dz As RadDockZone = Me.dzColumnOne
            Dim dl As RadDockLayout = Me.dlColumnOne
            dz.Controls.Add(dock)
            Me.CreateSaveStateTrigger(dock)
            dock.Tag = DocksDataTable.Rows(i).Item("ReportPath")
            Me.LoadUserControl(dock)
        Next
    End Sub

    Public Function ReturnReports() As DataTable
        Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("MidwestPartsConnectionString").ConnectionString)
        Dim Query As String = "SELECT Reports.ReportPath, Reports.ReportTitle, UserReports.UserID FROM UserReports INNER JOIN Reports ON UserReports.ReportID = Reports.ReportID WHERE (UserReports.UserID = @UserID)"
        Dim adapter As New SqlDataAdapter
        adapter.SelectCommand = New SqlCommand(Query, connection)
        adapter.SelectCommand.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier).Value = Me.LoginClass.ReturnUserID()
        Dim table1 As New DataTable
        connection.Open()
        Try
            adapter.Fill(table1)
        Finally
            connection.Close()
        End Try
        Return table1
    End Function

    Private Function ReturnLayout() As DataTable
        Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("MidwestPartsConnectionString").ConnectionString)
        Dim Query As String = "select * from sysproperties"
        Dim adapter As New SqlDataAdapter
        adapter.SelectCommand = New SqlCommand(Query, connection)
        adapter.SelectCommand.Parameters.Add("@UserPropertiesID", SqlDbType.Int).Value = 1
        Dim table1 As New DataTable
        connection.Open()
        Try
            adapter.Fill(table1)
        Finally
            connection.Close()
        End Try
        Return table1
    End Function

    Private Sub LoadUserControl(ByVal dock As RadDock)
        If String.IsNullOrEmpty(dock.Tag) Then
            Return
        End If
        Dim usercontrol As Control = LoadControl(dock.Tag)
        dock.ContentContainer.Controls.Add(usercontrol)
    End Sub

    Private Sub CreateSaveStateTrigger(ByVal dock As RadDock)
        dock.AutoPostBack = True
        dock.CommandsAutoPostBack = True
        Dim saveStateTrigger As New AsyncPostBackTrigger()
        saveStateTrigger.ControlID = dock.ID
        saveStateTrigger.EventName = "DockPositionChanged"
        UpdatePanel1.Triggers.Add(saveStateTrigger)
        saveStateTrigger = New AsyncPostBackTrigger()
        saveStateTrigger.ControlID = dock.ID
        saveStateTrigger.EventName = "Command"
        UpdatePanel1.Triggers.Add(saveStateTrigger)
    End Sub

    Private Sub CreateSavedLayout(ByVal JavascriptStr As String)
        Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("MidwestPartsConnectionString").ConnectionString)        
        Dim strSqlInsert As String = "INSERT INTO SysProperties(UserID, JavascriptStr) VALUES (@UserID, @JavascriptStr)"
        strSqlInsert += "; SELECT SCOPE_IDENTITY() ;"
        Dim sqlCmd As New SqlCommand(strSqlInsert, sqlConn)
        With sqlCmd.Parameters
            .Add("@JavascriptStr", SqlDbType.Text).Value = JavascriptStr
            .Add("@UserID", SqlDbType.UniqueIdentifier).Value = Me.LoginClass.ReturnUserID()
        End With
        sqlCmd.Connection.Open()
        sqlCmd.ExecuteScalar()
        sqlCmd.Connection.Close()
    End Sub


    Protected Sub btnAddReports_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddReports.Click
        Try
            Response.Redirect("~/MyUserAccount/SelectedReports.aspx", False)
        Catch ex As Exception

        End Try
    End Sub
End Class


Pero
Telerik team
 answered on 17 Aug 2010
1 answer
117 views
Hi,

I am using the asp.net ajax tab container. Inside each tab, I have a radgrid included. The radgrid has a "GridCreated" event attached in the clientsettings section. I am using this event to adjust the height and width dynamically. But somehow, the grid is not calling that event. Any suggestions?

Thanks,
sridhar.
Veli
Telerik team
 answered on 17 Aug 2010
2 answers
213 views
Hi

I am not sure if I am doing the wrong thing here. I have several flag imagebuttons in a master page,
but the tooltip does not display on hover. I can't see why not. They look like this:
<asp:ImageButton ID="ImageButtonChinese" runat="server" ImageUrl="~/images/flags/chinese-flag.gif" />
  
      <telerik:RadToolTip ID="RadToolTipChinese" runat="server" Animation="Fade" 
      TargetControlID="ImageButtonChinese" IsClientID="true" 
      Text="Click flag for Mandarin site" Position="TopRight" >
      </telerik:RadToolTip>

The image buttons are made visible or not in code behind, during the page load event.
What am I missing?

Thanks for help!

Clive

Clive
Svetlina Anati
Telerik team
 answered on 17 Aug 2010
1 answer
76 views
Good Day

Something Strange is happening  in my App.

I have a Button that Switches the controls no and off(Showing and Hiding)

and the code is like this

protected void btnCalender_Click(object sender, EventArgs e)
{
    RadToolBarItem textItem = RadToolBar1.FindItemByText("Button1");
    ImageButton btnCalender = (ImageButton)textItem.FindControl("btnCalender");
 
    if (RadGrid1.Visible == true)
    {
        //lblTestlabel.Visible = false;
        RadGrid1.Visible = false;
        RadScheduler1.Visible = true;
        LeftPane.Collapsed = false;
        btnCalender.ImageUrl = "~/images/Picture5.png";
 
 
    }
    else
    {
        RadGrid1.Visible = true;
        // lblTestlabel.Visible = true;
       RadScheduler1.Visible = false;
 
       LeftPane.Collapsed = false;
        btnCalender.ImageUrl = "~/images/CalenderView.png";
    }
     
 
     
}

and its working well , but now i have a Grid and that grid has paging and  its defined like this

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"
                AutoGenerateHierarchy="True" GridLines="None" Height="744px"
                ondetailtabledatabind="RadGrid1_DetailTableDataBind1"
                OnItemCommand="RadGrid1_ItemCommand" OnItemCreated="RadGrid1_ItemCreated"
                onneeddatasource="RadGrid1_NeedDataSource1" PageSize="10" Skin="Forest"
                Visible="False" Width="100%" AllowSorting="True">
                <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" />
                <ItemStyle HorizontalAlign="Center" />
                <MasterTableView>
                    <CommandItemSettings  ExportToPdfText="Export to Pdf" />
                    <PagerStyle AlwaysVisible="True" />
                </MasterTableView>
                <HeaderStyle HorizontalAlign="Center" />
                <AlternatingItemStyle HorizontalAlign="Center" />
            </telerik:RadGrid>

as you can see , when a Radgrid is visible the Radschedular needs to hidden, that works fine , until i start clicking on the pages of the grid, while paging, the Scheduler will appear at the bottom.

i need Help on that
Vuyiswa
Top achievements
Rank 2
 answered on 17 Aug 2010
2 answers
116 views
I have a template column. I dont want to export it.
I tried to do
1. Make the column visible=false before export
grd.Columns[0].Visible = false;

grd.MasterTableView.ExportToExcel();

grd.Columns[0].Visible =

true;

 


2. Add attribute.add to cell and make it visible = false.

e.Row.Cells[0].Attributes.Add(

"visible", "false");

 


3. Remove the cell

e.Row.Cells.RemoveAt(0);


However i was unsucessfull .. can you pls suggest a wasy so that the column is not exported and there is no blank column in the export

 

grd.ExportSettings.IgnorePaging =

true;

 

grd.ExportSettings.OpenInNewWindow =

true;

 

grd.ExportSettings.Excel.Format = Telerik.Web.UI.

GridExcelExportFormat.Html;

 

grd.ExportSettings.ExportOnlyData =

true;

 

Sabyasachi Dechaudhari
Top achievements
Rank 1
 answered on 17 Aug 2010
1 answer
77 views
Hai,

How to get a node selected and highlighted it with a different color on pageload. I have tried selectedNode, selectedText but in vein.
Shinu
Top achievements
Rank 2
 answered on 17 Aug 2010
1 answer
1.3K+ views
How can i set the selected index of a combobox in javascript.

eg: i wish to set the index to the first option upon when a check box is unchecked.
Shinu
Top achievements
Rank 2
 answered on 17 Aug 2010
1 answer
135 views
Hi there,
When I use this code:
protected void RadGridPhaseGroup_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
            LinkButton addButton = e.Item.FindControl("InitInsertButton") as LinkButton;
            addButton.Text = "Add new group";
        }
    }

It will change my add new item button name. However, I'm using the hierarchy grid. Are there any ways that i would be able to change the add button name of the outer grid to " Add new group" and the title of the add button name of the inner grid to "Add phase"?
The code above change the add button title for both the outer and inner grid.
Thanks in advance
Shinu
Top achievements
Rank 2
 answered on 17 Aug 2010
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?