Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
254 views
We are using the latest service pack of the Q3 2008 RadGrid. My grid has 2 levels of hierarchy, the first level is just a list of people's names and the second level is detailed information about their order.

Below is the NeedDataSource function. DataSourcePeople is a datatable stored in viewstate.
Private Sub grdPerson_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdPerson.NeedDataSource 
        grdPerson.DataSource = DataSourcePeople 
    End Sub 

When the grid runs it's PreRender event, it runs the following code. This is used to look in the DataSource (another datatable with their order information) to see if the row has been previously selected so that we can reselect the items after paging, sorting, etc.
Private Sub grdPerson_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles grdPerson.PreRender 
        For Each item As Telerik.Web.UI.GridItem In grdPerson.MasterTableView.ItemsHierarchy 
            If item.OwnerTableView.Name = "Detail" Then 
                If DataSource.Select("ResourceID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("ResourceID") & "' AND PersonID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("PersonID") & "'").Length > 0 Then 
                    If DataSource.Select("ResourceID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("ResourceID") & "' AND PersonID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("PersonID") & "'")(0)("Selected") = True Then 
                        item.Selected = True 
                    Else 
                        item.Selected = False 
                    End If 
                End If 
            End If 
        Next 
    End Sub 

When a user expands a person to see their orders the following code is run in the DetailTableDataBind event. The ExpandPerson function simply finds all of the person's orders and adds them to the DataSource data table so that it can be bound.
Dim dataitem As Telerik.Web.UI.GridDataItem = CType(e.DetailTableView.ParentItem, Telerik.Web.UI.GridDataItem) 
 
        If DataSource.Select("PersonID = '" & dataitem.GetDataKeyValue("PersonID") & "'").Length = 0 Then 
            ExpandPerson(dataitem.GetDataKeyValue("PersonID")) 
        End If 
 
        e.DetailTableView.DataSource = DataSource.Select("PersonID = '" & dataitem.GetDataKeyValue("PersonID") & "'""Course ASC"

Finally, we have our event (the ItemCommand) to track what was changed in the detail table so that we can reselect them when the user expands the person again (assuming they do expand the person after collapsing them). This appears to be where the trouble begins.
Private Sub grdPerson_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdPerson.ItemCommand 
        If e.CommandName = "ExpandCollapse" Then 
            For Each item As Telerik.Web.UI.GridItem In grdPerson.MasterTableView.ItemsHierarchy 
                If item.Selected Then 
                    If DataSource.Select("ResourceID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("ResourceID") & "' AND PersonID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("PersonID") & "'").Length > 0 Then 
                        Dim dr As DataRow = DataSource.Select("ResourceID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("ResourceID") & "' AND PersonID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("PersonID") & "'")(0) 
                        dr("Selected") = True 
                        dr("Hours") = CType(item.FindControl("txtHours"), TextBox).Text 
                        dr("Minutes") = CType(item.FindControl("txtMinutes"), TextBox).Text 
                        dr("Score") = CType(item.FindControl("txtScore"), TextBox).Text 
                        dr("CompletionDate") = CType(item.FindControl("txtCompletionDate"), TextBox).Text 
                        dr("CompletionDeadline") = CType(item.FindControl("txtCompletionDeadline"), TextBox).Text 
                    End If 
                Else 
                    If DataSource.Select("ResourceID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("ResourceID") & "' AND PersonID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("PersonID") & "'").Length > 0 Then 
                        DataSource.Select("ResourceID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("ResourceID") & "' AND PersonID = '" & item.OwnerTableView.DataKeyValues(item.ItemIndex).Item("PersonID") & "'")(0)("Selected") = False 
                    End If 
                End If 
            Next 
        End If 
    End Sub 

The initial NeedDataSource to populate the people's names works just fine. When a user clicks on the button to expand the grid it runs the events in the following order:
  1. ItemCommand (ExpandCollapse)
  2. NeedDataSource
  3. DetailTableDataBind
  4. PreRender
When a user collapses the person after expanding them it runs the following events:
  1. ItemCommand (ExpandCollapse)
  2. PreRender
The problem occurs when I select something before collapsing. This causes it to run the following events:
  1. ItemCommand (ExpandCollapse, it updates the DataSource data table with the correct values)
  2. PreRender
  3. NeedDataSource
  4. DetailTableDataBind

Their are few problems with this. First, it doesn't collapse as it should. Second, even though it doesn't collapse it loses it's selection (since the PreRender event doesn't fire to reselect it). Other columns (for example Score, Hours, etc.) show with the values entered. Any idea why it would decide to run the NeedDataSource and DetailTableDataBind after updating the data. My first inclination was that it was doing this because it detected that it's data sources have changed and therefore it needed to rebind, however, just because it rebinds doesn't mean that it shouldn't still collapse as it's supposed to.

Any help would be greatly appreciated. The end goal is that I can have a grid that I can expand and collapse correctly and it would keep the items selected inside of the detail table when I would expand to view it again.

Thanks,
Adam
Adam
Top achievements
Rank 1
 answered on 27 Mar 2009
1 answer
140 views
Hi.

The company I am working uses the RadNumericInput control with it's language set to Danish (Denmark).

The problem occurs when you click from the RadNumericInput's autocomplete dropdown.
When I doubleclick the RadNumericInput control,  I have these numbers listed in the autocomplete dropdown.

400.000
444444
444.444
500.000
555.555

If I select a number and lost focus from the RadNumericInput control, the following happens.

400.000 -> 400                         // any characters starting from the thousand separator to the end of the entry are being
                                                     disregarded if it contains zeroes.
444444  -> 444 444                  // the value was formatted but the thousand separator becomes space character
444.444  -> 444 444                 // the thousand separator becomes space character
500.000  -> 500                        // any characters starting from the thousand separator to the end of the entry are being
                                                     disregarded if it contains zeroes.
555.555  -> 555 555                 // the thousand separator becomes space character

Is there any way to fix this?

Thank you and best regards,
Raffy

Daniel
Telerik team
 answered on 27 Mar 2009
1 answer
95 views

Hi

In my application i have a simple grid where i need to make some operations is in DisplayMode and some other actions if the grid is in EditMode so i simply use the condition below, but for a reason that i dont unserstand the code inside the condition is executed even if i try to insert a new item. When i check the type of e.item it is a GridDataInsertItem and not a GridDataItem  but the code inside the condition is still executed... I'm sure i'm missing something obvious but i cant figured out what it can be...

 Private Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound  
         
 
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then 
'the grid is EditMode  
            Dim Item As GridEditableItem = e.Item  
 
              
        End If 
 
        If TypeOf (e.Item) Is GridDataItem Then 
 
'the grid is not in editMode (DisplayMode)  
            Dim dataBoundItem As GridDataItem = e.Item  
'throw the conversion error because i dont have any ID yet  
            Dim ID As Integer = dataBoundItem("DbId").Text  
 
             
        End If 
 
    End Sub 

Thanks in advance for your help.
Dominic
Top achievements
Rank 2
 answered on 27 Mar 2009
2 answers
75 views
I have a page (with a master page) and when I place the TabStrip as the first item on the page, it renders in the middle of the page (about 500 pixels from the top). I have tried placing it in a table and that does not change it. I have tried it with and without a related MultiPage object. I have tried this on 2 separate pages with no luck.

Q1 2008 Ajax
VS 2008

cdikmen
Top achievements
Rank 1
 answered on 27 Mar 2009
0 answers
131 views
Disregard. Sorry.


Karl Wilkens
Top achievements
Rank 1
 asked on 27 Mar 2009
3 answers
151 views
I'm working on my departments first Telerik-driven AJAX app and I must say I love the controls.  Unfortunately, however, we are limited at a corporate level to using only IE6, so a lot of my time is spent hacking CSS files.  I am using the RadMenu extensively and have doctored up our own skin using the Default skin as a template.  I've only done minor customizations to the CSS since the default is so close to our corporate standards of look-and-feel (changes only to color).

The issue I am having is with the separator.  No matter what I try, I cannot get the separator to show up in IE6.  I have Firefox installed locally for debug purposes and the separator shows up just fine.  I have not changed the separator styles in any way from the original.  I looked through the forums and saw that the Vista skin had a somewhat similar issue, so I created a png of the divider from a screenshot and tried embedding that into the CSS.  Again, I could get it to show up in Firefox but not IE.  The spacing of the menu is correct (you see the space where the dividing line SHOULD be, but not the line itself).

Since I'm relatively new to the controls, I am out of ideas.  I could go without using the dividers if I have to, but the menus we are using are pretty extensive and the dividers will aid the users visually in a big way.  If there are any ideas, I would appreciate the assistance.  I'm not attaching any code because everything being used regarding the dividers is the Default skin out of the box.

Thanks in advance,
Doug
Doug
Top achievements
Rank 1
 answered on 27 Mar 2009
3 answers
111 views
we have a grid that is beign populated with contact information.
i see there is a way to tie into the event when page is changed..
i can store that page index in a session variable etc...
but i am curious on how to set the grid to that page number at runtime...i am would assume i would set it right after i set the datasource and before i exit out of the needdatasource method? but not sure how.

also i need to save the sort expression and order as far as asc and desc and apply it at runtime

any advice or samples would be appreciate
Yavor
Telerik team
 answered on 27 Mar 2009
4 answers
349 views
I am getting some weird behaviour.

This is a bit of aspx in user control I have:

   <Telerik:RadScriptBlock ID="cb1" runat="server"
 
                <script type="text/javascript" language="javascript"
                   var myValue = '' 
                   function getSelectedRowValue() 
                    { 
                        if (myValue) 
                            return myValue; 
                        else 
                            return ''; 
                    }         

This will only be rendered after an ajax request.

When it is rendered I get some very strange stuff added to the head of my page

Firebug reports:

<link rel="stylesheet" href="\r\n var myValue = \u0027\u0027\r\n function getSelectedRowValue()\r\n {\r\n if (myValue)\r\n return myValue;\r\n else\r\n return \u0027\u0027;\r\n } \r\n function RowSelected(sender"
1<html> 
<head> 
<title>Bad Request</title> 
<style> 
5 body {font-family:"Verdana";font-weight:normal;font-size: 8pt;color:black;} 
6 p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} 
7 b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} 
8 h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } 
9 h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } 
10 pre {font-family:"Lucida Console";font-size: 8pt} 
11 .marker {font-weight: bold; color: black;text-decoration: none;} 
12 .version {color: gray;} 
13 .error {margin-bottom: 10px;} 
14 .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } 
15 </style> 
16 </head> 
17 <body bgcolor="white"
18 
19 <span><h1>Server Error in '/SafetyTortilla' Application.<hr width=100size=1 color=silver></h1> 
20 
21 <h2> <i>HTTP Error 400 - Bad Request.</i> </h2></span
22 
23 <hr width=100size=1 color=silver
24 
25 <b>Version Information:</b>&nbsp;ASP.NET Development Server 8.0.0.0 
26 
27 </font> 
28 
29 </body> 
30</html> 
31 
</link> 


I tried this in Opera Dragonfly as well.

I cannot find the javascript anywhere else.

Martin


Yuriy Rogach
Top achievements
Rank 1
Iron
 answered on 27 Mar 2009
4 answers
367 views
I have a RadGrid that I want to select a row, click a button and use the values from the selected row somewhere else.  I am able to highlight the row and SelectedIndexChanged fires but I cannot seem to get the correct syntax to get the data from the grid.  I am using the following example in C# I found in the fourm.  I want to convert this to VB.

I can't get the Format Code block to work correctly so it's a little sloppy...

Protected Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles RadGrid1.SelectedIndexChanged

foreach (GridDataItem item in   RadGrid1.MasterTableView.Items) 

{ If (item.Selected) Then 

        {  

            string strTxt = item["ProductName"].Text;  

        }

}

 

 

End Sub

I am able to do this and loop through each row in the grid.  It will loop through 10 times which is the number of rows in the grid:

 For Each GridDataItem RadGrid1.MasterTableView.Items

  'Do something here
Next 

 

 

But when I try to define the "item" I get errors.  I tried this:

For Each Item As GridDataItem In RadGrid1.MasterTableView.Items 

   'Do Something Here   Next

And This:
Dim Item As GridDataItem (I get error here telling me GridDataItem is not defined)

For Each GridDataItem In RadGrid1.MasterTableView.Items
   'Do Something Here  

 

Next

 

 

What Am I missing here?


Eric Turner
Top achievements
Rank 1
 answered on 27 Mar 2009
13 answers
368 views
Hello

I programmatic create a Grid with AutoGenerateCollumns = true
after the Bind how can I remove some column ?

would be client or server side..

my PROC is returning these fields

cod,productdescription,value

and with autogenerate = true all fields will bind to the grid

can I remove "COD" after the grid is builded ?

NOTE : I Will Use the field COD as a relation field with the detail table.


theres a way to make it invisible?

thank you
Bruno
Top achievements
Rank 1
 answered on 27 Mar 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?