Telerik Forums
UI for ASP.NET AJAX Forum
15 answers
1.7K+ views
Hello,

I did find some information, but that was on other forums. 

Now we have DynamicObject (or ExpandoObject, that's an implementation of DynamicObject as I understood) we, of course, want it to bind to a RadGrid. There is no thread or blog I can find on this issue. It's also a bit of a Sunday afternoon thing for now.

I was wondering what Telerik thinks of this usage, what would be your approach..
And also this tread can grow to be of use to others, that's the main gaol..

We have a dynamic class:
Imports System.IO
Imports System.Dynamic
  
Public Class DynamicDictionary
    Inherits DynamicObject
  
    ' The inner dictionary.
    Dim mdic_PropertyHolder As New Dictionary(Of String, Object)
  
    ' This property returns the number of elements in the inner dictionary.
    ReadOnly Property Count As Integer
        Get
            Return mdic_PropertyHolder.Count
        End Get
    End Property
  
  
    ReadOnly Property Items As Dictionary(Of String, Object)
        Get
            Return mdic_PropertyHolder
        End Get
    End Property
  
    Public Function GetMembers() As String()
        Return mdic_PropertyHolder.Keys.ToArray
    End Function
  
    Public Property Item(ByVal PropertyName As String) As String
        Get
            Return mdic_PropertyHolder(PropertyName)
        End Get
        Set(ByVal value As String)
            mdic_PropertyHolder(PropertyName) = value
        End Set
    End Property
  
    ' If you try to get a value of a property that is not defined in the class, this method is called.
    Public Overrides Function TryGetMember(ByVal binder As System.Dynamic.GetMemberBinder, ByRef result As Object) As Boolean
        ' Converting the property name to lowercase
        ' so that property names become case-insensitive.
        Dim name As String = binder.Name.ToLower()
  
        ' If the property name is found in a dictionary, set the result parameter to the property value and return true. Otherwise, return false.
        Return mdic_PropertyHolder.TryGetValue(name, result)
    End Function
  
    Public Overrides Function TrySetMember(ByVal binder As System.Dynamic.SetMemberBinder, ByVal value As Object) As Boolean
  
        ' Converting the property name to lowercase so that property names become case-insensitive.
        mdic_PropertyHolder(binder.Name.ToLower()) = value
  
        ' You can always add a value to a dictionary, so this method always returns true.
        Return True
    End Function
  
  
End Class

In a asp.net page we have:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" GridLines="None" Width="100%" ShowGroupPanel="True" AllowSorting="True" ShowStatusBar="true">
    <MasterTableView RetrieveAllDataFields="true" AutoGenerateColumns="false">
        <Columns>
            <telerik:GridTemplateColumn HeaderText="Hopa" >
                <ItemTemplate>
                    <span style="white-space:nowrap"><%# Container.DataItem.firstname%></span>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn HeaderText="FirstName" DataField="FirstName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="MiddleName" DataField="MiddleName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

In a asp.net page code we have:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim person As Object
    Dim List As New ArrayList
    ' Adding new dynamic properties.
    ' The TrySetMember method is called.
    person = New DynamicDictionary()
    person.FirstName = "Ellen"
    person.LastName = "Adams"
    List.Add(person)
    person = New DynamicDictionary()
    person.FirstName = "Piet"
    person.LastName = "Pietersen"
    List.Add(person)
    person = New DynamicDictionary()
    person.FirstName = "Erik"
    person.MiddleName = "van der"
    person.LastName = "Heide"
    List.Add(person)
    person = New DynamicDictionary()
    person.FirstName = "Jan"
    person.LastName = "Janssen"
    List.Add(person)
    RadGrid1.DataSource = List
    RadGrid1.DataBind()
End Sub
Private Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
    If TypeOf e.Item Is GridDataItem Then
        Dim dataBoundItem As GridDataItem = e.Item
        For Each Member As String In dataBoundItem.DataItem.GetMembers
            Try
                dataBoundItem(Member).Text = dataBoundItem.DataItem.Item(Member)
            Catch ex As Exception
                ' Oops
            End Try
        Next
    End If
End Sub


This is of course not verry fast, but verry flexible it is. Editing is an issue I think, but displaying is not.

Regards,

Erik
Attila Antal
Telerik team
 answered on 05 Mar 2019
5 answers
773 views

Hi,

 

I have a page where I user a RadWindowManager and buttons calling postback functions.
To open my RadWindow, I use this traditional code : 

    var oWnd = $find("<%= RadWindow.ClientID %>");
    oWnd.show();

It work fine until one button is fired and postback is done.
After that postback, $find return null every time.

Does someone have a tips to resolve that issue ?

Thanks,
Corentin

Rumen
Telerik team
 answered on 05 Mar 2019
20 answers
980 views
I implemented MultiColumn Headers on my radGrid, very cool!

Exporting to Excel however is not doing so great. It only takes the lowest level headers, but with column span of the top level, causing all sorts of wierdness....

Any suggestions on how to export the grid as is, meaning all levels of the headers and data?
Attila Antal
Telerik team
 answered on 05 Mar 2019
7 answers
668 views

I have two RadListBoxes I am able to drag and drop items between the two without problems, but I have one specific RadlistItem that when I add it to the other listbox I want to remove the existing list items in the code behind, but so far it keeps giving and error like Outside Index or something similar when I try to remove those list Items.  Any help or Ideas would be appreciated.

 

Thanks,

Peter Milchev
Telerik team
 answered on 05 Mar 2019
4 answers
368 views

hi,

just like james in this thread, I need to mark certain rows according to a condition.
every time the user opens and watch an idea, the row of the watched idea should be in lightblue.
that for itself works great.
My problem is, that when I click a row it gets lightblue, but then- when I  click another row, the previous row change color to white.
How can I keep the condition working for alternating item style too?

that my code :

<telerik:RadGrid Skin="innovation" EnableEmbeddedSkins="false" ID="RadGrid1" 
              dir="rtl" HeaderStyle-ForeColor="White" AllowFilteringByColumn="True"  
    AllowSorting="True" AllowPaging="True"  BorderColor="#74ABAE" BackColor="White"
    BorderWidth="2px" runat="server" HeaderStyle-Font-Size="Small"  ItemStyle-Font-Size="Small"
    AlternatingItemStyle-Font-Size="Small" ItemStyle-BackColor="White" ItemStyle-ForeColor="Black"
     PageSize="7" AutoGenerateColumns="False" PagerStyle-Font-Size="Small" 
     AlternatingItemStyle-ForeColor="Black"
   Culture="Hebrew" GridLines="Vertical" Width="666px" 
      style="margin-right: 30px">
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Black">
    </HeaderContextMenu>
        <ItemStyle BackColor="White" Font-Size="Small" ForeColor="Black" />
    <PagerStyle mode="NumericPages" ShowPagerText="false"></PagerStyle>
    <MasterTableView>
    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
           <Columns>
                 <telerik:GridBoundColumn CurrentFilterFunction="Contains"
                     DataField="IDEA_CODE" UniqueName="IDEA_CODE" HeaderText="ideanum"
                      AutoPostBackOnFilter="true" DataType="System.Int32"
                    </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn UniqueName="LINK" DataField="LINK" HeaderText="" 
                    DataType="System.String" Display="false"
                    </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="ROWNUM" HeaderText="#" Visible="false"
                 AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.Int32">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SENDER_ID" HeaderText="id"
                UniqueName="SENDER_ID" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.String">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FULLNAME" HeaderText="namef"
                AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.String">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SUBJECT" HeaderText="sub"
                AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.String">
                </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="DESCRIPTION" HeaderText="status"
                 AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.String">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SEND_DATE" HeaderText="sdate"
                AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.DateTime" DataFormatString="{0:dd/MM/yy}">
                </telerik:GridBoundColumn>                 
                  <telerik:GridImageColumn HeaderText="comments" UniqueName="FBIMG">
                </telerik:GridImageColumn>    
         
     </Columns>
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
        <HeaderStyle Width="20px">
        </HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
        <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <EditFormSettings>
        <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
        </EditFormSettings>
        </MasterTableView>
              <SelectedItemStyle BackColor="LightBlue" />
        <HeaderStyle ForeColor="White"></HeaderStyle>
               <ClientSettings>
               <Selecting AllowRowSelect="true" />
               <ClientEvents OnRowSelected="OpenIdea" />                   
                </ClientSettings>
        <FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
        Try
            If TypeOf e.Item Is GridDataItem Then
                Dim item As GridDataItem = CType(e.Item, GridDataItem)
                Dim idea_code As Integer = CInt(item("IDEA_CODE").Text)
                If (StoredProcedures.Is_Watched_Idea(idea_code, userID) = True) Then 'if the ideas was watched then
                    item.BackColor = Drawing.Color.LightBlue 'color the row
                     End If
….
End sub

by the way- I tried disable alternating row in client settings but all I got is a transparent back color for the alternative rows.

can anyone help with that?
kind regards, Dana
yasmin Ahmad
Top achievements
Rank 2
 answered on 05 Mar 2019
3 answers
326 views

How can I disable RadDropDownTree node based on nodeid?

I want to disable the first and second node in the tree based on the database nodeid 1 and 2

Peter Milchev
Telerik team
 answered on 04 Mar 2019
4 answers
592 views
I have a RadGrid that contains a GridTableView in the DetailTables, as such:

<telerik:RadGrid ID="RelatedProductsGrid" runat="server" Width="95%" ShowStatusBar="true"
            AutoGenerateColumns="False" PageSize="20" AllowSorting="False" AllowMultiRowSelection="False"
            AllowPaging="True">
            <pagerstyle mode="NextPrevAndNumeric"></pagerstyle>
            <mastertableview width="100%" datakeynames="PartId" allowmulticolumnsorting="False">
        <DetailTables>
            <telerik:GridTableView DataKeyNames="PartId" Name="RelatedProducts" Width="100%">
                <Columns>

...

<telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                        <ItemTemplate>
                            <telerik:RadButton ID="RemoveRelatedProductButton" runat="server" CommandName="Delete">
                            </telerik:RadButton>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </telerik:GridTableView>
        </DetailTables>

So, the above button, "RemoveRelatedProductButton" shows up allright, but whenever I press it - nothing happens.

I have this in the code behind:

_relatedProductsGrid = FindControl("RelatedProductsGrid") as RadGrid;
_relatedProductsGrid.ItemCommand += RelatedProductsGrid_ItemCommand;

And finally:

protected void RelatedProductsGrid_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")

etc.

However, this method never fires. What do I need to do?
Tonya
Top achievements
Rank 1
 answered on 04 Mar 2019
4 answers
1.3K+ views
How implement "OnClientClicked" to GridButtonColumn?
Travis Richardson
Top achievements
Rank 1
 answered on 04 Mar 2019
1 answer
593 views

When I upgrade an existing project to a newer version the Upgrade Wizard Log shows success but I get this error:

https://drive.google.com/open?id=1l1KqfmqRnsCgWJ5O5LeBDCH_fpjDoiRr

Also if I bring up the Launch Toolbox Configurator and then click "Finish" button, I get the same error.

I do NOT run VS 2015 "As Admin" for many reason I don't want to get into, so please don't suggest that ;)  

Cheers, Rob.

Rumen
Telerik team
 answered on 04 Mar 2019
5 answers
252 views
Hi All

I have an ASP.NET datalist which is displaying data in the form of a repeated list.

I have set the RepeatColumns to 6, so that I have the data displayed repeatedly in 6 columns.

Is there a telerik control that can do this, ie repeat the data in columns?

I tried using a RadGrid but cannot get the data to display in 6 columns.

Any help is very much appreciated.

Thanks

Johann  
Rumen
Telerik team
 answered on 04 Mar 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?