Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
67 views
I have a requirement from client to hide grid header when there is no record, but the insert edit form need to be shown up by default. Here is the code in PreRender event. The code does do the job, however, the insert edit form is shift to right dramatically and cut off part of it.  After study the run-time source code, I found out there is an empty table cell  before the insert edit form table. And same thing for "No record to display" message. Is there a way that insert edit form's colspan property can cover that empty table cell?
protected void rgDrugs_PreRender(object sender, EventArgs e) 
 { 
     int iCount = 0
        foreach(GridDataItem item in rgDrugs.Items) 
        { 
            if (item!=null) 
            { 
                iCount++; 
            } 
        } 
       if (iCount==0) 
       { 
           rgDrugs.ShowHeader = false
       }else 
       { 
           rgDrugs.ShowHeader = true
       } 
        if (rgDrugs.EditItems.Count>0) 
        { 
            rgDrugs.MasterTableView.IsItemInserted = false
        }else 
        { 
            rgDrugs.MasterTableView.IsItemInserted = true
        } 
        rgDrugs.MasterTableView.Rebind(); 
Georgi Krustev
Telerik team
 answered on 11 May 2009
1 answer
116 views
Hi

I have a window (skin black) which is positioned relative to a div and appears when the div
is clicked. The final position is correct relative to the div but for a brief moment the window
appears relative to the browser rather than the div then jumps to the correct position.

Animation is set to 'fade' so this should not be happening should it?
Can it be prevented? It spoils what is basically a very slick UI.

Thanks

Clive

Q1 2009 version
Georgi Tunev
Telerik team
 answered on 11 May 2009
7 answers
407 views
Hi,

I'm looking to do a user configuration page that is somewhat complex and would like some advice on if it is possible with the Rad controls as they are now.

I want to have a treeview showing a location heirarchy on the left that the user can drill down into.  On each drilled down row I'd like to see several columns representing options for each - something like the following. Note that each circle is a checkbox NOT a radio button - I couldn't find a square on the keyboard ;)

---------------------------Option 1 ----------- Option 2 --------------- Option 3 -----
O America                      O                           O                                O
    O New York                O                           O                                O
    O Boston                    O                           O                                O
    O Miami                      O                           O                                O
O England                      O                           O                                O
    O London                   O                           O                                O
    O Bristol                      O                           O                                O
    O Newcastle                O                           O                                O

What I'd like to do is then allow for the user to click the parent level and have it's setting cascade to the children ie someone clicks America Option 1, all of the cities in America would then be ticked for Option 1.  Then for Option 2, just Boston gets a tick.

Please tell me this is possible (and hopefully easy to do).  It will make my life a lot easier if it is possible!

If not possible then I'll probably get around it by having an option drop down above a tree view and you choose the option to work on one at a time.

Regards,

Jon
Veselin Vasilev
Telerik team
 answered on 11 May 2009
2 answers
115 views
Is there a way to set spacing between Rad Docks, we have two verticle columns defined for 2 RadDockZones and I fill them with rad docks dynamically. I dont want to define 7 or 8 seperate Zones and when the docks render they do so on top of one aother with zero spacing.

Thanks,
Sam
Sam
Top achievements
Rank 1
 answered on 11 May 2009
1 answer
280 views
I have a user control which has a 4-tab tab strip inside.  Each of those tabs in turn render child user controls.  In two of those child controls I have a RadGrid.  I am having a lot of rendering issues with those grids inside the child controls that I do not have elsewhere in the application (I am using the grid extensively to replace an Access application and I have the grid pretty much down and many times copy and paste one set of grid code to another with very few changes).  Some notes:

1.  I use static headers on all the grids
2.  I define each column in the grid as well as explicitly define widths
3.  I use all the resizing and re-ordering bells and whistles

The grids inside the tabstrip/multipage render horribly.  Margins are off, title columns are not aligned with data columns, reordering one column in one grid throws off the margins of the other grid in the other tab, etc.  The strange this is that it is random and intermittent.  One time I load the page everything will look fine.  Refresh the page and everything could be off.  Close the browser and reload the app, everything could be off.  Refresh the page again and it looks fine.  I am using IE6 as per our corporate standards and am binding the data using NeedDataSource with a LINQ to SQL stored procedure.  I cannot give out data details, but snippets of code showing the basic configuration is below.  I don't seem to have this problem except for when I place a grid inside a tabstrip.  Any help would be appreciated.

Thanks,
Doug

Parent Control Code:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MappingTables.ascx.cs" Inherits="LEBrowser.Content.Controls.WorkPanel.MappingTables" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<%@ Register src="/Content/Controls/Tabs/AddressTypes.ascx" tagname="AddressTypes" tagprefix="VZW" %> 
<%@ Register src="/Content/Controls/Tabs/ContactTypes.ascx" tagname="ContactTypes" tagprefix="VZW" %> 
<%@ Register src="/Content/Controls/Tabs/LegalEntityTypes.ascx" tagname="LegalEntityTypes" tagprefix="VZW" %> 
<%@ Register src="/Content/Controls/Tabs/PhoneFaxTypes.ascx" tagname="PhoneFaxTypes" tagprefix="VZW" %> 
 
<table width="100%">  
    <tr> 
        <td width="30%" align="left" valign="middle">  
            <span class="WorkPanelTitle">  
                <asp:Literal runat="server" ID="litMappingTablesTitle">  
                    Mapping Tables  
                </asp:Literal> 
            </span>               
        </td> 
    </tr> 
</table> 
<asp:Image ID="imgDivider" AlternateText="Work Panel Divider" ImageUrl="~/Content/Images/WorkPanelDivider.png" runat="server" /> 
<telerik:RadTabStrip ID="tabMappingTables" runat="server" Width="100%"   
    ShowBaseLine="True" ReorderTabsOnSelect="True" MultiPageID="mpMappingTables">  
    <Tabs> 
        <telerik:RadTab runat="server" Text="Address Types" Selected="true">  
        </telerik:RadTab> 
        <telerik:RadTab runat="server" Text="Contact Types">  
        </telerik:RadTab> 
        <telerik:RadTab runat="server" Text="Legal Entity Types">  
        </telerik:RadTab> 
        <telerik:RadTab runat="server" Text="Phone/Fax Types">  
        </telerik:RadTab> 
    </Tabs> 
</telerik:RadTabStrip> 
<telerik:RadMultiPage ID="mpMappingTables" runat="server" SelectedIndex="0">  
    <telerik:RadPageView ID="pvAddressTypes" runat="server">  
        <VZW:AddressTypes ID="vzwAddressTypes" runat="server" /> 
    </telerik:RadPageView> 
    <telerik:RadPageView ID="pvContactTypes" runat="server">  
        <VZW:ContactTypes ID="vzwContactTypes" runat="server" /> 
    </telerik:RadPageView> 
    <telerik:RadPageView ID="pvLegalEntityTypes" runat="server">  
        <VZW:LegalEntityTypes ID="vzwLegalEntityTypes" runat="server" /> 
    </telerik:RadPageView> 
    <telerik:RadPageView ID="pvPhoneFaxTypes" runat="server">  
        <VZW:PhoneFaxTypes ID="vzwPhoneFaxTypes" runat="server" /> 
    </telerik:RadPageView> 
</telerik:RadMultiPage> 
 

Child control example (Address Type)

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AddressTypes.ascx.cs" Inherits="LEBrowser.Content.Controls.Tabs.AddressTypes" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<br /> 
<div class="Center">  
    <span class="WorkWindowMessage">  
        <asp:Label ID="lblAddressTypesMessage" runat="server">&nbsp;</asp:Label> 
    </span> 
</div> 
<div class="Grid">  
  <telerik:RadGrid ID="gridAddressTypes" runat="server" GridLines="None" AllowPaging="True" AllowFilteringByColumn="True" 
      AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="true" OnPreRender="gridAddressTypes_PreRender" 
      OnNeedDataSource="gridAddressTypes_NeedDataSource" OnUpdateCommand="gridAddressTypes_UpdateCommand" 
      OnInsertCommand="gridAddressTypes_InsertCommand" OnDeleteCommand="gridAddressTypes_DeleteCommand" 
      OnCancelCommand="gridAddressTypes_CancelCommand" Width="850" Height="400">  
      <MasterTableView CommandItemDisplay="Top" DataKeyNames="MappingTableID">  
          <CommandItemSettings AddNewRecordText="Add New Address Type" /> 
          <Columns> 
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">  
                            <ItemStyle Width="30" /> 
            </telerik:GridEditCommandColumn> 
            <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" 
                            ConfirmDialogType="RadWindow" ConfirmTitle="Confirm Address Type Delete" 
                            ConfirmText="Are You Sure You Want To Delete This Address Type?  This will also delete any items associated with this Address Type!">  
                            <ItemStyle Width="30" /> 
                        </telerik:GridButtonColumn> 
            <telerik:GridBoundColumn UniqueName="ShortDescription" HeaderText="Short Description" DataField="ShortDescription">  
                            <ItemStyle Width="125" /> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Description" HeaderText="Description" DataField="Description">  
                            <ItemStyle Width="420" /> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="IsActive" HeaderText="Active" DataField="IsActive">  
                            <ItemStyle Width="98" /> 
            </telerik:GridBoundColumn> 
          </Columns> 
          <EditFormSettings UserControlName="~/Content/Controls/GridForm/AddressType.ascx" EditFormType="WebUserControl">  
                        <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
                        <FormStyle BackColor="White" /> 
          </EditFormSettings> 
      </MasterTableView> 
      <clientsettings AllowColumnsReorder="True">  
                <scrolling allowscroll="True" usestaticheaders="True" /> 
                <Resizing AllowColumnResize="True" EnableRealTimeResize="True" /> 
            </clientsettings> 
  </telerik:RadGrid> 
</div> 
using System;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Telerik.Web.UI;  
using VZWTaxAPICoreLibrary.Managers;  
using VZWTaxAPICoreLibrary.Objects.Generic;  
using VZWTaxAPICoreLibrary.Objects.Security;  
 
namespace LEBrowser.Content.Controls.Tabs  
{  
    public partial class AddressTypes : UserControl  
    {  
        private readonly MappingManager MappingManager = new MappingManager();  
        private User SessionUser;  
 
        protected void Page_Load(object sender, EventArgs e)  
        {  
            SessionUser = Global.GetSessionUser(Session.SessionID);  
        }  
 
        protected void gridAddressTypes_PreRender(object sender, EventArgs e)  
        {  
            if (!IsPostBack)  
            {  
                gridAddressTypes.MasterTableView.Items[1].Edit = true;  
                gridAddressTypes.MasterTableView.Rebind();  
            }  
        }  
 
        protected void gridAddressTypes_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)  
        {  
            gridAddressTypes.DataSource = MappingManager.GetAddressTypes();  
        }  
 
        protected void gridAddressTypes_InsertCommand(object sender, GridCommandEventArgs e)  
        {  
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);  
            MappingTable newMappingTable = new MappingTable  
                                            {  
                                                ShortDescription = (userControl.FindControl("txtShortDescription"as TextBox).Text,  
                                                Description = (userControl.FindControl("txtDescription"as TextBox).Text,  
                                                                                IsActive = (userControl.FindControl("chkIsActive"as CheckBox).Checked  
                                            };  
 
            if (!MappingManager.CheckDuplicateAddressType(newMappingTable))  
            {  
                MappingManager.InsertAddressType(newMappingTable, SessionUser.UserID);  
                lblAddressTypesMessage.Text = "Address Type Successfully Added!";  
            }  
            else 
            {  
                e.Canceled = true;  
                lblAddressTypesMessage.Text = "An Address Type With The Same Identifier Already Exists!";  
            }  
        }  
 
        protected void gridAddressTypes_UpdateCommand(object sender, GridCommandEventArgs e)  
        {  
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);  
            MappingTable updateMappingTable = new MappingTable  
                                                {  
                                                    MappingTableID =  
                                                        Convert.ToInt32((userControl.FindControl("txtAddressTypeID"as TextBox).Text),  
                                                    ShortDescription =  
                                                        (userControl.FindControl("txtShortDescription"as TextBox).Text,  
                                                    Description = (userControl.FindControl("txtDescription"as TextBox).Text,  
                                                                                        IsActive = (userControl.FindControl("chkIsActive"as CheckBox).Checked,  
                                                                                    };  
 
            MappingManager.UpdateAddressType(updateMappingTable, SessionUser.UserID);  
            lblAddressTypesMessage.Text = "Address Type Successfully Updated!";  
        }  
 
        protected void gridAddressTypes_DeleteCommand(object sender, GridCommandEventArgs e)  
        {  
            string sAddressTypeID = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["MappingTableID"].ToString();  
            MappingManager.DeleteAddressType(Convert.ToInt32(sAddressTypeID), SessionUser.UserID);  
        }  
 
        protected void gridAddressTypes_CancelCommand(object sender, GridCommandEventArgs e)  
        {  
            lblAddressTypesMessage.Text = "&nbsp;";  
        }  
    }  
Georgi Krustev
Telerik team
 answered on 11 May 2009
1 answer
113 views
I'm having a problem with using a RadTreeView as combo Dropdow.
I can't find a way to let the user unselect a node. I'm using the folowing script. The combo shows the empty text, but the tree node does not get unselected.

function OnClientNodeClickingHandler(sender, eventArgs) {

  var combo = $find('COMBO_ID');

  var tree = $find('TREE_ID');

 

  var node = eventArgs.get_node();  

  if (node.get_selected()) {

    tree.trackChanges();

    node.unselect();

    tree.commitChanges();

    combo.set_text(combo.get_emptyMessage());

    combo.trackChanges();

    combo.get_items().getItem(0).set_value('');

  } else {

    combo.set_text(node.get_text());

    combo.trackChanges();

    combo.get_items().getItem(0).set_value(node.get_value());

  }

  combo.commitChanges();

  combo.hideDropDown();

  window.event.cancelBubble = true;

}

 

 

 

Yana
Telerik team
 answered on 11 May 2009
7 answers
196 views
I had wanted to use 
 <Scrolling AllowScroll="true" SaveScrollPosition="false" UseStaticHeaders="true"/>
and


<GroupByExpressions>
                                            <telerik:GridGroupByExpression>
                                                <GroupByFields>
                                                    <telerik:GridGroupByField FieldAlias="FoundIn" FieldName="FoundIn" HeaderValueSeparator=" : "
                                                        SortOrder="Ascending" />
                                                </GroupByFields>
                                                <SelectFields>
                                                    <telerik:GridGroupByField FieldAlias="FoundIn" FieldName="FoundIn" />
                                                </SelectFields>


but this causes either the vertical scroll to collapse completely,

помоги
Dimo
Telerik team
 answered on 11 May 2009
3 answers
237 views
Hi, 

I'm using a asp:DetailsView with different fields, and one of them is : 

<asp:TemplateField HeaderText="Type d'affaire"
    <ItemTemplate> 
        <%#Eval("TypeAffaire.Libelle")%> 
    </ItemTemplate> 
    <EditItemTemplate> 
        <telerik:RadComboBox ID="RadComboBoxTypeAffaire" runat="server" Skin="Hay"  
            DataSourceID="LinqDataSourceTypeAffaire" DataTextField="Libelle" 
            DataValueField="IdTypeAffaire" SelectedValue='<%# Bind("TypeAffaire.IdTypeAffaire") %>'
        </telerik:RadComboBox> 
        <asp:LinqDataSource ID="LinqDataSourceTypeAffaire" runat="server"  
            ContextTypeName="isiweb.Common.DAO.LinqToSqlDataContext"  
            TableName="TypeAffaires"
        </asp:LinqDataSource> 
    </EditItemTemplate> 
</asp:TemplateField> 

When I switch to edit mode, the comboBox take the right value with the SelectedValue='<%# Bind("TypeAffaire.IdTypeAffaire") %>'> After, I change de value... And I click on Update. I go on OnItemUpdated to see what happen and I see that 1 row is affected... It's great...

But, when I'm back to the 'normal' mode, the value of the combobox go back to the old value. :o

Do you fine a problem with my code ? 
Thank you, 

Jean-Yves
Veselin Vasilev
Telerik team
 answered on 11 May 2009
1 answer
214 views
I'm having some difficulty binding the GridDropDownListColumnEditor for an "InPlace" insert on a grid that is initially loaded with no records. I've gone through the forums, and I've implemented several of the suggested solutions to no avail. The DropDownList displays with no records bound to it. Am I doing something wrong?

To provide some context, I am looking to avoid SqlDataSource controls, as it would break away from our current architecture. I was able to bind the grid by using a SqlDataSource and setting the DataSourceID property of the GridDropDownColumn, but in doing that, I lost the formatting provided by the columneditor control.

Please advise...

Here is my code (ASPX):

                                        <telerik:RadGrid ID="grdClientAddresses" runat="server"  
                                            OnItemDataBound="grdClientAddress_ItemDataBound"  
                                            Visible="true"  
                                            AutoGenerateColumns="false"  
                                            Skin="Office2007"  
                                            Width="800"  
                                            AllowPaging="true"
                                            <MasterTableView  
                                                EditMode="InPlace"  
                                                CommandItemDisplay="Top"   
                                                DataKeyNames="ClientAddressID"
                                                <CommandItemSettings  
                                                    AddNewRecordText="New Address"  
                                                    AddNewRecordImageUrl="/images/office.png"  
                                                    RefreshText="Reload" />                                                  
                                                <NoRecordsTemplate> 
                                                    No addresses exist for this client. Use the fields above to create a new address 
                                                </NoRecordsTemplate>                                                                                           
                                                <Columns>                                                     
                                                    <telerik:GridBoundColumn UniqueName="Address_StreetAddress"  
                                                        HeaderText="Street Address"  
                                                        ColumnEditorID="StreetAddressColumnEditor"  
                                                        HeaderStyle-Width="400"  
                                                        ItemStyle-Width="400"  
                                                        DataField="StreetAddress"
                                                    </telerik:GridBoundColumn> 
                                                    <telerik:GridBoundColumn UniqueName="Address_City"  
                                                        HeaderText="City"  
                                                        ColumnEditorID="CityColumnEditor"  
                                                        DataField="City"  
                                                        HeaderStyle-Width="260"  
                                                        ItemStyle-Width="260"
                                                    </telerik:GridBoundColumn> 
                                                    <telerik:GridDropDownColumn UniqueName="Address_StateID"  
                                                        DataField="StateID"  
                                                        ColumnEditorID="StateColumnEditor"  
                                                        HeaderText="State"  
                                                        HeaderStyle-Width="50"  
                                                        ItemStyle-Width="50"
                                                    </telerik:GridDropDownColumn> 
                                                    <telerik:GridBoundColumn UniqueName="Address_ZipCode"  
                                                        HeaderText="Zip"  
                                                        DataField="Zip"  
                                                        ColumnEditorID="ZipCodeColumnEditor"  
                                                        HeaderStyle-Width="90"  
                                                        ItemStyle-Width="90"
                                                    </telerik:GridBoundColumn> 
                                                </Columns>                                                                                                  
                                            </MasterTableView>                                                                                                                                                                                                                              
                                        </telerik:RadGrid>                                                 
                                        <telerik:GridDropDownListColumnEditor ID="StateColumnEditor" runat="server" 
                                            DataTextField="StateAbbr"  
                                            DataValueField="StateID"  
                                            DropDownStyle-Width="50"
                                        </telerik:GridDropDownListColumnEditor>                                                                                
                                        <telerik:GridTextBoxColumnEditor ID="StreetAddressColumnEditor" runat="server" 
                                            TextBoxStyle-Width="350"
                                        </telerik:GridTextBoxColumnEditor> 
                                        <telerik:GridTextBoxColumnEditor ID="CityColumnEditor" runat="server"  
                                            TextBoxStyle-Width="220"
                                        </telerik:GridTextBoxColumnEditor> 
                                        <telerik:GridTextBoxColumnEditor ID="ZipCodeColumnEditor" runat="server"  
                                            TextBoxStyle-Width="60"
                                        </telerik:GridTextBoxColumnEditor>  






And my code behind OnItemDataBound event:

        protected void grdClientAddress_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if (e.Item.IsInEditMode) 
            { 
                if (e.Item is GridEditableItem) 
                { 
                    //first reference the edited grid item    
                    GridEditableItem EditableItem = e.Item as GridEditableItem; 
                    GridEditManager EditableItemMgr = EditableItem.EditManager; 
 
                    //reference the column editor which holds the dropdown list instance in the edit form   
                    GridDropDownColumnEditor StateDropDownEditor = EditableItemMgr.GetColumnEditor("Address_StateID"as GridDropDownColumnEditor; 
 
                    //bind the column editor 
                    StateDropDownEditor.DataSource = base.DataPortal.GetStates(); 
                    StateDropDownEditor.DataTextField = "StateAbbr"
                    StateDropDownEditor.DataValueField = "StateID"
                    StateDropDownEditor.DataBind(); 
 
                    StateDropDownEditor.SelectedIndex = 0; 
                } 
            }    
        } 
                               
 Thanks!              


Georgi Krustev
Telerik team
 answered on 11 May 2009
1 answer
224 views
I'm currently using the following to prevent the data in the grid from wrapping -


 Protected Sub RadGrid1_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles RadGrid1.ColumnCreated  
        'prevent grid details from wrapping  
        If (TypeOf e.Column Is Telerik.Web.UI.GridBoundColumn) Then  
            CType(e.Column, Telerik.Web.UI.GridBoundColumn).DataFormatString = "<nobr>{0}</nobr>" 
        End If  
    End Sub 

This works great until I try to export the grid using ExportToCSV().

 Protected Sub lnkBtnCSV_Click(ByVal sender As Object, ByVal e As System.EventArgs)  
        RadGrid1.ExportSettings.ExportOnlyData = True 
        RadGrid1.ExportSettings.IgnorePaging = True 
        RadGrid1.ExportSettings.OpenInNewWindow = True 
        RadGrid1.MasterTableView.ExportToCSV()  
    End Sub 


I get the "<nobr>1</nobr>" in the exported file. Is a way around this? The ExportToWord and ExportToExcel seem to already ignore the tags.

current output:
"CallID","CallNumber","CallType"  
"<nobr>1</nobr>","<nobr>1</nobr>","<nobr>Voice</nobr>"  
 
Want it to be this:  
"CallID","CallNumber","CallType"  
"1","1","Voice" 


Sebastian
Telerik team
 answered on 11 May 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?