Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
264 views

Folks,

I am trying to retain the values in a detail grid after a griddropdowncolumn event fire (selectedindexchanged event ). I am extracting the values (current cell values) of the grid in a session variable and changing some properties for a column depending on the selected value in dropdown in the selectedindexchanged event (then I am rebinding the grid to see the effects of changed properties). Then in grid prerender event I am trying to set the cell values from the session variable, Here comes the problem, I am unable to find the detail grid items to set the cell values.

I am binding the grid on the server (using needdatasource event and detailtablebind events).

For your reference, I have included my selectedindexchanged event and grid prerender events here

Private Sub List_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)  
 
            Dim editedItem As GridEditableItem = CType(CType(sender, RadComboBox).NamingContainer, GridEditableItem)  
            Dim ddlChsnMthd As RadComboBox = CType(editedItem("CHSN_MTHD_ID").Controls(0), RadComboBox)  
            Dim insertItem As GridDataItem = DirectCast(CType(sender, RadComboBox).NamingContainer, GridDataItem)  
            Dim insertVals As Hashtable = New Hashtable  
 
            RadGrid1.MasterTableView.ExtractValuesFromItem(insertVals, insertItem)  
            Session("insertvals") = insertVals  
 
            If ddlChsnMthd.SelectedValue = 4 Then 
                RadGrid1.MasterTableView.DetailTables.Item(0).Columns.Item(9).Visible = True 
            Else 
                RadGrid1.MasterTableView.DetailTables.Item(0).Columns.Item(9).Visible = False 
            End If 
 
            RadGrid1.MasterTableView.Rebind()  
 
End Sub

 

Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender     
    
    
           If Not Session("insertvals") Is Nothing AndAlso RadGridTransCalc.MasterTableView.DetailTables.Item(0).IsItemInserted Then    
                Dim insertvals As Hashtable = CType(Session("insertvals"), Hashtable)     
                Dim insertItem As GridEditableItem = DirectCast(RadGridTransCalc.MasterTableView.DetailTables.Item(0).GetInsertItem(), GridEditableItem)     
                If Not insertvals("ID") Is Nothing Then TryCast(insertItem("ID").Controls(0), RadComboBox).SelectedValue = insertvals("ID")     
                If Not insertvals("CALC_DATE") Is Nothing Then TryCast(insertItem("CALC_DATE").Controls(0), RadDatePicker).SelectedDate = CDate(insertvals("CALC_DATE"))     
                If Not insertvals("STRT_TIME") Is Nothing Then TryCast(insertItem("STRT_TIME").Controls(0), RadTimePicker).SelectedDate = CDate(insertvals("STRT_TIME"))     
                If Not insertvals("END_TIME") Is Nothing Then TryCast(insertItem("END_TIME").Controls(0), RadTimePicker).SelectedDate = CDate(insertvals("END_TIME"))     
                If Not insertvals("COND_ID") Is Nothing Then TryCast(insertItem("COND_ID").Controls(0), RadComboBox).SelectedValue = insertvals("COND_ID")     
                If Not insertvals("MTHD_ID") Is Nothing Then TryCast(insertItem("MTHD_ID").Controls(0), RadComboBox).SelectedValue = insertvals("MTHD_ID")     
          End If    
 
End Sub   
 

Does anyone came across this scenario, please help.

Thanks,

Kevin

Kevin
Top achievements
Rank 1
 answered on 05 Feb 2010
1 answer
108 views
This is my first encounter with RadMenu, so I just copied directly from the online example and modified it to fit my column names:

<telerik:RadContextMenu ID="radContextMenu1" runat="server" Skin="Forest" OnClientItemClicked="ClientItemClicked">  
    <Items> 
        <telerik:RadMenuItem Text="Show Column">  
            <Items> 
                <telerik:RadMenuItem Text="MDEP" /> 
                <telerik:RadMenuItem Text="MDEP Description" /> 
                <telerik:RadMenuItem Text="OA" /> 
                <telerik:RadMenuItem Text="OA Description" /> 
                <telerik:RadMenuItem Text="EOR" /> 
                <telerik:RadMenuItem Text="EOR Description" /> 
                <telerik:RadMenuItem Text="ASN" /> 
                <telerik:RadMenuItem Text="ASN Description" /> 
                <telerik:RadMenuItem Text="APC" /> 
                <telerik:RadMenuItem Text="APC Description" /> 
                <telerik:RadMenuItem Text="FY06" /> 
                <telerik:RadMenuItem Text="FY07" /> 
                <telerik:RadMenuItem Text="FY08" /> 
                <telerik:RadMenuItem Text="FY09" /> 
            </Items> 
        </telerik:RadMenuItem>   
        <telerik:RadMenuItem Text="Hide Column" /> 
    </Items>   
    <Targets> 
        <telerik:ContextMenuTagNameTarget TagName="thead" /> 
    </Targets>   
</telerik:RadContextMenu>  

The menu pops up on right mouse-click populated with all the menu items.  When I click on a menu item the following javascript is invoked, again copied verbatum from the online example:

function ClientItemClicked( sender, eventArgs ) {  
    activeTable = $find( "<%= radGrid1.ClientID %>" ).get_masterTableView();  
    colIndex = GetRealCellIndex( activeTable, eventArgs.get_gridColumn().get_element());  
 
    switch( eventArgs.get_item().get_text() ) {  
        case "MDEP" :  
            activeTable.showColumn( 0 );  
            break;  
 
        case "MDEP Description" :  
            activeTable.showColumn( 1 );  
            break;  
 
        case "OA" :  
            activeTable.showColumn( 2 );  
            break;  
 
        case "OA Description" :  
            activeTable.showColumn( 3 );  
            break;  
 
        case "EOR" :  
            activeTable.showColumn( 4 );  
            break;  
 
        case "EOR Description":  
            activeTable.showColumn( 5 );  
            break;  
 
        case "ASN":  
            activeTable.showColumn( 6 );  
            break;  
 
        case "ASN Description":  
            activeTable.showColumn( 7 );  
            break;  
 
        case "APC":  
            activeTable.showColumn( 8 );  
            break;  
 
        case "APC Description":  
            activeTable.showColumn( 9 );  
            break;  
 
        case "FY06":  
            activeTable.showColumn( 10 );  
            break;  
 
        case "FY07":  
            activeTable.showColumn( 11 );  
            break;  
 
        case "FY08":  
            activeTable.showColumn( 12 );  
            break;  
 
        case "FY09":  
            activeTable.showColumn( 13 );  
            break;  
 
        case "Hide Column" :  
            activeTable.hideColumn( colIndex );  
            break;     
 
        default :  
            break;  
    }  
} 

And no matter what menu item I click on a get a JavaScript "Property Not Supported" error.  The cause of this is apparently

                    colIndex = GetRealCellIndex( activeTable, eventArgs.get_gridColumn().get_element());


So I commented it out and then all I get is the [undefined] JavaScript error.

Can someone please give me a clue, because I obviously don't have one?

Thanks,
Mark
Mark Galbreath
Top achievements
Rank 2
 answered on 05 Feb 2010
7 answers
169 views

 

I have a combo box that I populate with with searchig a db once the user has typed at least two characters. How do I make sure that the user actually selects one of the returned items and doesn't simply type a few characters and move on? I need the value in the control to be one of the returned items whether the user types it all the way out or selects an option after the LoadOnDemand. Is there a property I am not using correctly or a client side script approach?

 

 <telerik:RadComboBox ID="cboAccounts" runat="server" Width="300" Font-Size="11px"
                        EnableLoadOnDemand="true" AllowCustomText="false" MarkFirstMatch="true" EnableTextSelection="true"
                        EmptyMessage="Search/Select an Account" IsCaseSensitive="false" EnableItemCaching="true"
                        LoadingMessage="Fetching matching items..." ShowDropDownOnTextboxClick="false"
                        Height="100" AutoPostBack="true" CausesValidation="false">
                        <ExpandAnimation Duration="200" />
                        <CollapseAnimation Duration="200" />
 </telerik:RadComboBox>
 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="cboAccounts"
                        runat="server" ErrorMessage="*" CssClass="ErrorMsg"></asp:RequiredFieldValidator>

 

     Private Sub cboAccounts_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles cboAccounts.ItemsRequested

        If e.Text <> String.Empty And Len(e.Text) >= 2 Then
            Dim dtbl As DataTable = SearchAccounts("", e.Text, Url.GetPath(), ActiveUser.UserID)

            For Each row As DataRow In dtbl.Rows
                Dim item As New RadComboBoxItem(row("account_name").ToString() & " (" & row("account_type").ToString() & ")", row("account_no").ToString())
                cboAccounts.Items.Add(item)
            Next
        End If
    End Sub

    Private Function SearchAccounts(ByVal top As String, ByVal prefixText As String, ByVal path As String, ByVal user_id As String) As DataTable
        Dim dvw As DataTable

        With New VBDataLayer.SqlServer(conStr)
            .AddParameter("@top", top)
            .AddParameter("@prefixText", prefixText)
            .AddParameter("@path", path)
            .AddParameter("@user_id", user_id)
            .AddParameter("@version", CStr(Session("version")))
            dvw = .RunProc("wsp_web_Search_Accounts2", "Accounts").Tables(0)
        End With

        Return dvw
    End Function

 

 

 

Kalina
Telerik team
 answered on 05 Feb 2010
1 answer
282 views

I have a stored procedure that accepts a parameter ("UserID") via a session variable, and returns specific data.  The data in question comprises of multiple columns containing branch number, and address.  I have tested this query, and it performs correctly, returning the necessary data.  However, when testing the page (and combo box), the combo box does not list the data, but rather has an item in it that says "System.Data.DataRowView" - and nothing else.  This has me a little lost, as I am not certain why it is doing this.  Here's the requisite code:

'This is the code behind code for the page_load event;  
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
 
        Dim conn As New SqlClient.SqlConnection  
        Dim cmd As New SqlClient.SqlCommand  
 
        MemUser = Membership.GetUser()  
        UserID = MemUser.UserName.ToString()  
 
        Session("UserID") = UserID & "@tscgrpsolutions.com" 
 
    End Sub 
<!-- Here's the combo box & datasource--> 
<telerik:RadComboBox ID="ddlSelectStore" runat="server" Skin="Black" Width="300px"   
        DataSourceID="sqlStoreSelect">  
</telerik:RadComboBox> 
 
<!-- Data Connections--> 
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server"   
    ConnectionString="<%$ ConnectionStrings:xxxxxxxxxx%>"   
    SelectCommand="StoreSelectCommand" SelectCommandType="StoredProcedure">  
    <SelectParameters> 
        <asp:SessionParameter DefaultValue="xxxxxxxxxxxxxx"   
            Name="RepName" SessionField="UserID" Type="String" /> 
    </SelectParameters> 
</asp:SqlDataSource> 

The data returned comprises of 4 or 5 columns. 

Update: I did try doing a SQL select command directly to the database from the ASP.NET data source, and was able to populate the combo box. HOWEVER, the first item in the combo box still says "System.Data.DataRowView", and I cannot select any of the items the combo box is populated with. I have no idea why...

Any direction would be appreciated.
Kalina
Telerik team
 answered on 05 Feb 2010
4 answers
343 views
After playing with the stylesheets, i still can't get rid of the vertical divider.
Consider the following menu (I'm using the default skin):-
Menu 1 | Menu 2 | Menu 3

I need it to be :-
Menu 1  Menu 2  Menu 3

How can I achieve this?
Mark Galbreath
Top achievements
Rank 2
 answered on 05 Feb 2010
1 answer
129 views
Hi Telerik team,

I am facing one problem with use of RadAjaxPanel. I have following code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxPanel.aspx.cs" Inherits="WebApplication10.AjaxPanel" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
    <img src="<%= MyServer + "images/uparrow.gif"%>" /> 
    <telerik:RadScriptManager ID="mgr1" runat="server"></telerik:RadScriptManager> 
    <telerik:RadAjaxPanel ID="panel1" runat="server"></telerik:RadAjaxPanel> 
    </div> 
    </form> 
</body> 
</html> 
================================== 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
 
namespace WebApplication10 
{ 
    public partial class AjaxPanel : System.Web.UI.Page 
    { 
        public string MyServer { get { return "http://server/"; } } 
        protected void Page_Load(object sender, EventArgs e) 
        { 
 
        } 
    } 
} 

This code throws error  "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."

If I wrap RadAjaxPanel in another div(server control) then code works as expected.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxPanel.aspx.cs" Inherits="WebApplication10.AjaxPanel" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
    <img src="<%= MyServer + "images/uparrow.gif"%>" /> 
    <telerik:RadScriptManager ID="mgr1" runat="server"></telerik:RadScriptManager> 
    <div id="wrapper" runat="server"> 
    <telerik:RadAjaxPanel ID="panel1" runat="server"></telerik:RadAjaxPanel> 
    </div> 
    </div> 
    </form> 
</body> 
</html> 
 

So I have a working solution for such problem, But can anyone provide more insight into this?

Regards
Shrikant


Pavlina
Telerik team
 answered on 05 Feb 2010
2 answers
478 views
In a grid I have some money data.  I've right align the column values but since they don't line up well with the column header and the next column I'm adding two nbsp characters to the right of the value - in order to provide a little padding.  These values when exported into Excel also have these padding characters.  Unfortunately these space charaters prevent Excel autosum from working correctly.  Even reformatting the Excel column doesn't work.

The question are ...

- Can I right align the values but have a little space to the right of the value without using space characters
- Is it possible to intercept the data before exporting to Excel and remove the space characters?
- In Excel how can one remove the padding characters easily?

Sphengle
Top achievements
Rank 1
 answered on 05 Feb 2010
2 answers
79 views
I would like to obtain the Column name and the direction of the sort when the user clicks a header name.  I'll be storing this in a cookie so that the next time the page is visited, I can automatically sort the grid to display what they last viewed.  How do I do this?

Thanks

Vincent
vincent
Top achievements
Rank 1
 answered on 05 Feb 2010
3 answers
164 views
Hi,

on your Roadmap stands:

RadEditor

  • Light version of some editor dialogs
  • RTF, PDF Export/Import
  • Thumbnail functionality
  • RadScriptManager and RadStyleSheetManager used in editor's dialogs

is the Thumbnail functionality the long awaited thumbnails preview function in the Image manager?
This is not in PITS??

Please give some more information on this...

BR,
Marc
Rumen
Telerik team
 answered on 05 Feb 2010
16 answers
720 views
How do you set cursor position on RadDateInput, RadEditor, textbox Inside RadGrid, all RAD Controls.
Especially if the rad control is built in .ascx  and added to the aspx.
I try to set focus and tabindex but they dont really work well. Using rad control cursor doesnt even blink.
What is the best way to set the cursor on a first editable control. Is it better in Javascript or in page load event inside cs file?
Please help and provide a sample code.
Joselito
Top achievements
Rank 1
 answered on 05 Feb 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?