Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
263 views
I load a RadCombo box via a store procedure.  To that list I want to add an "All" item at position 0.

I tried doing it this way:

 

protected void rcbYear_PreRender(object sender, EventArgs e)
        {
            RadComboBox combo = sender as RadComboBox;
            if (ViewState[combo.ClientID] != null)
            {
                var rcbi = new RadComboBoxItem();
                rcbi.Attributes.Add("0", "All");
                combo.Items.Insert(0, rcbi);
                combo.DataBind();
            }
        }

I verified that when the combo box comes in has the values from the store proc.  The method runs normally but the combo ends with the same items as when it came in.

Any ideas?

a.wilks
Top achievements
Rank 1
 answered on 12 Sep 2012
1 answer
125 views
<telerik:RadGrid ID="rgLabelManager" runat="server" Skin="ARC" AutoGenerateColumns="false" 
GridLines="None" AllowSorting="true" AllowPaging="true" PageSize="10" 
OnNeedDataSource="LabelManager_NeedDataSource" OnItemDataBound="LabelManager_ItemDataBound"
OnUpdateCommand="LabelManager_UpdateCommand" OnInsertCommand="LabelManager_InsertCommand">
<
PagerStyle Mode="NextPrevAndNumeric" />        
<MasterTableView Width="100%" AutoGenerateColumns="false" EditMode="InPlace" 
CommandItemDisplay="TopAndBottom">
<Columns>
<telerik:GridTemplateColumn  UniqueName="ContactName" SortExpression="LastName" HeaderText="Contact Name" 
ItemStyle-Width="60%" ItemStyle-HorizontalAlign="Left">
<ItemTemplate> <%#((String)DataBinder.Eval(Container.DataItem, "FirstName")).Substring(0,1).ToUpper()%>
<%
#((String)DataBinder.Eval(Container.DataItem, "FirstName")).Substring(1).ToLower()%>   
<%#((String)DataBinder.Eval(Container.DataItem, "LastName")).Substring(0,1).ToUpper()%>
<%
#((String)DataBinder.Eval(Container.DataItem, "LastName")).Substring(1).ToLower()%>
</ItemTemplate>
<EditItemTemplate>

<telerik:RadComboBox ID="rcbContactName" runat="server" EnableVirtualScrolling="true"
ShowMoreResultsBox="true" ItemsPerRequest="10" EnableLoadOnDemand="true" Width="400" 
OnClientItemsRequesting
="GenericRadCombo_OnClientItemsRequesting" 
OnClientItemsRequested
="rcbLookupContact_OnClientItemsRequested" 
OnClientDropDownClosing
="rcbLookupContact_OnClientDropDownClosing">
<
WebServiceSettings Method="LookupContact" Path="~/service/scriptservice.asmx" />
</telerik:RadComboBox> &nbsp;&nbsp;
<asp:LinkButton runat="server" ID="lbAdd" Text="Add New Contact" style="display:none;" 
OnClick="lnkAddContact_Click"></asp:LinkButton>
</EditItemTemplate>
</telerik:GridTemplateColumn> 

I want to access "lbAdd" from Javascript and keep getting error that lbAdd in not in the context. I've tried
$find('<%=lbAdd.ClientID %>')  and 
document.getElementById("<%=lbAdd.ClientID %>")

Please let me know if I'm missing something to access lbAdd - I need to change the display based on different conditions.
Princy
Top achievements
Rank 2
 answered on 12 Sep 2012
3 answers
122 views
Hi All,

      How to make a StackPanel dockable vertically.

Thanks in Advance.
Princy
Top achievements
Rank 2
 answered on 12 Sep 2012
3 answers
181 views
Hello everyone,
I'm searching for a solution to set a DropDownWidth in my GridDropDownColumn.
I'm loading the Grid dynamically, just like this demo and I want to be able to edit and insert data in this Grid.
So there are this GridDropDownColumns and the text is showing in two lines, but I want to be able to set the width so that the text is in one line and the Combobox of this GridDropDownColumns is larger. Is there a solution for this problem?

Thanks in advance,
Esmi
Shinu
Top achievements
Rank 2
 answered on 12 Sep 2012
3 answers
85 views
here my code:
KTFrameworkCusEntities dcc = new KTFrameworkCusEntities();
IQueryable<
udv_Articles> _udvResult;
    public IEnumerable<udv_Articles> getAllArticleByCat(int catid)
    {
  
        //KTFrameworkCusEntities dc = new KTFrameworkCusEntities();
        //_udvPro = null;
        _udvResult = dcc.udv_Articles.Include("udv_Categories").Where(t => t.ArticleID == 99999999);
        loadArticlebyCate(catid);
        return _udvResult.OrderByDescending(t => t.UpdatedDate).ToList();
    }
  
    protected IQueryable<udv_Articles> loadArticlebyCate(int caid)
    {
        //KTFrameworkCusEntities dc = new KTFrameworkCusEntities();
  
        Func<KTFrameworkCusEntities, IQueryable<udv_Articles>> _IEProList = CompiledQuery.Compile((KTFrameworkCusEntities ne) => ne.udv_Articles.Include("udv_Categories").Where(t => t.udv_Categories.CateID == caid));
  
        if (_IEProList(dcc).Count() > 0)
        {
            _udvResult = _udvResult.Concat(_IEProList(dcc));
        }
        IEnumerable<udv_Categories> _IECatList = dcc.udv_Categories.Where(c => c.ParentID == caid);
        if (_IECatList.Count() > 0)
        {
            foreach (var item in _IECatList)
            {
                loadArticlebyCate(item.CateID);
            }
        }
  
        return _udvResult;
    }
 
IQueryable<udv_Categories> _udvResult2;
    public IEnumerable<udv_Categories> getAllCategoriesByCat(int catid)
    {
        //KTFrameworkCusEntities dc = new KTFrameworkCusEntities();
        //_udvPro = null;
        _udvResult2 = dcc.udv_Categories.Where(t => t.CateID == 99999999);
        loadCategorybyCate(catid);
        return _udvResult2.Where(t => t.IsActive == true).OrderBy(t => t.DisplayOrder).ToList();
    }
 
    protected IQueryable<udv_Categories> loadCategorybyCate(int caid)
    {
        //KTFrameworkCusEntities dc = new KTFrameworkCusEntities();
 
        Func<KTFrameworkCusEntities, IQueryable<udv_Categories>> _IEProList = CompiledQuery.Compile((KTFrameworkCusEntities ne) => ne.udv_Categories.Where(t => t.ParentID == caid));
 
        //IEnumerable<udv_Categories> _IEProList = dc.udv_Categories.Where(t => t.ParentID == caid);
        //IEnumerable<udv_Articles> _IEProList = from c in dc.udv_Articles where c.udv_Categories.CateID == caid select c;
        if (_IEProList(dcc).Count() > 0)
        {
            _udvResult2 = _udvResult2.Concat(_IEProList(dcc));
        }
        IEnumerable<udv_Categories> _IECatList = dcc.udv_Categories.Where(c => c.ParentID == caid);
        if (_IECatList.Count() > 0)
        {
            foreach (var item in _IECatList)
            {
                loadCategorybyCate(item.CateID);
            }
        }
        return _udvResult2;
 
    }

<telerik:RadGrid ID="RadGrid1" AllowFilteringByColumn="true" PageSize="20" ShowFooter="True"
    AllowPaging="True" AutoGenerateColumns="false" GridLines="None" ShowStatusBar="true"
    runat="server" OnItemDataBound="RadGrid1_ItemDataBound">
    <GroupingSettings CaseSensitive="false" />
    <MasterTableView EditMode="InPlace" AllowFilteringByColumn="True" ShowFooter="True"
        DataKeyNames="ArticleID" TableLayout="Fixed">
        <Columns>
            <telerik:GridBoundColumn DataField="Title" HeaderText="Tiêu đề" AutoPostBackOnFilter="true"
                CurrentFilterFunction="Contains" ShowFilterIcon="false">
                <HeaderStyle Width="25%" />
            </telerik:GridBoundColumn>
 
           <telerik:GridTemplateColumn DataField="CateID" HeaderText="Danh mục" UniqueName="CateID"
                    HeaderStyle-Width="200px" SortExpression="DisplayOrder">
                    <FilterTemplate>
                        <telerik:RadComboBox ID="RadComboBoxCategories" DataTextField="Title"
                        
                            DataValueField="CateID" Height="100px" AppendDataBoundItems="true"
                            runat="server" >
                            <Items>
                                <telerik:RadComboBoxItem Text="All" />
                            </Items>
                        </telerik:RadComboBox>                          
                    </FilterTemplate>
                    <ItemTemplate>
                       <%# Eval("udv_Categories.Title") %>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

if(!ispostback){
  RadGrid1.DataSource = getAllArticleByCat(113);
                RadGrid1.DataBind();
}
 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridFilteringItem)
        {
            GridFilteringItem item = (GridFilteringItem)e.Item;
            RadComboBox combo = (RadComboBox)item.FindControl("RadComboBoxCategories");
            using (dmsFunction dmsf = new dmsFunction())
            {
                combo.DataSource = getCategoryByParent(113).ToList();
                combo.DataBind();
                combo.AutoPostBack = true;
                combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);
            }
        }
    }
 
    void combo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
       // Custom Filter: Call getAllArticleByCat(Convert.ToInt32(combo.SelectedValue)) to get all Article by Categories
       // Then RadGrid Filter
          // Teach me how... Thanks
    }
Shinu
Top achievements
Rank 2
 answered on 12 Sep 2012
0 answers
81 views
Hi guys,

I have a problem in displaying the data from an sql table in an hierarchic way, as you can see in the screenshot (http://agileprecis.com/db-diagram.jpg), the table tasks will contain endless sub tasks for each task and it's using the referewnce ParentTaskID.

The problem in the grid display is it is displaying the subTasks as a normal row, wil it shouldn't appear unless i expand the specific node.

below is the code i'm using:
<telerik:RadGrid ID="DataGrid" runat="server" ShowStatusBar="True" AllowFilteringByColumn="True"                    AllowAutomaticUpdates="false" Width="100%" AllowAutomaticInserts="false" AllowAutomaticDeletes="false"
AllowPaging="True" PageSize="7" ShowGroupPanel="True">
<MasterTableView AutoGenerateColumns="False" AllowSorting="true" CommandItemDisplay="Top"
AllowAutomaticUpdates="false" AllowAutomaticInserts="false" AllowAutomaticDeletes="false"
HierarchyDefaultExpanded="false" HierarchyLoadMode="Client" DataKeyNames="TaskID, ParentTaskID" Width="100%">
                                                                
<SelfHierarchySettings ParentKeyName="ParentTaskID" KeyName="TaskID" />
<HeaderStyle HorizontalAlign="Center" /><FilterItemStyle HorizontalAlign="Center" />
<NoRecordsTemplate>No Records Found.</NoRecordsTemplate>
<Columns>
<telerik:GridButtonColumn UniqueName="Edit" CommandName="Edit" ButtonType="ImageButton"
 ImageUrl="~/Styles/images/icon_edit.gif" Text="Edit" HeaderText="Edit">
<HeaderStyle Width="35px" HorizontalAlign="center" />
 </telerik:GridButtonColumn>
 
<telerik:GridBoundColumn DataField="TaskID" Visible="True" HeaderText="TaskID" ReadOnly="True"
SortExpression="TaskID" UniqueName="TaskID"></telerik:GridBoundColumn>
                                                                     
<telerik:GridBoundColumn DataField="TaskTitle" HeaderText="TaskTitle" SortExpression="TaskTitle"
UniqueName="TaskTitle"> </telerik:GridBoundColumn>
                                                                     
<telerik:GridBoundColumn DataField="ParentTaskID" HeaderText="ParentTaskID" SortExpression="ParentTaskID"
Visible="True" UniqueName="ParentTaskID"> </telerik:GridBoundColumn>
                                                                 
</Columns>
</MasterTableView>
</telerik:RadGrid>

Thanks for your support
Mike_T
Top achievements
Rank 1
 asked on 11 Sep 2012
5 answers
176 views

I'm using a client-side API to start the spell check process.

I'm using onchange client-side event to launch the SpellCheck dialog.

However, the SpellCheck dialog still appears & says "The spell check is complete!" even there are no misspelled words.

How can I suppress the SpellCheck dialog when there are no mispelled words ?

-JScript-

 

function MultipleTextSource(sources) {
    this.sources = sources;
    this.get_text = function () {
        var texts = [];
        for (var i = 0; i < this.sources.length; i++) {
            texts[texts.length] = this.sources[i].get_text();
        }
        return texts.join("<controlSeparator><br/></controlSeparator>");
    }
    this.set_text = function (text) {
        var texts = text.split("<controlSeparator><br/></controlSeparator>");
        for (var i = 0; i < this.sources.length; i++) {
            this.sources[i].set_text(texts[i]);
        }
    }
}

function spellCheck(obj, field) {
    var sources =
               [
               new Telerik.Web.UI.Spell.HtmlElementTextSource($get(field))
               ];
    var spell = GetRadSpell(obj);
    spell.set_textSource(new MultipleTextSource(sources));
    spell.startSpellCheck();
}

 

-ASPX-

<telerik:RadSpell ID="RadSpell1" runat="server"  />

<asp:TextBox ID="TextBox1" runat="server" />


-Code Behind-

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 TextBox1.Attributes.Add("onchange", "spellCheck('" & RadSpell1.ClientID & "','" & TextBox1.ClientID & "')")

End Sub

 

Martha
Top achievements
Rank 1
 answered on 11 Sep 2012
2 answers
50 views
I run the attached sample and add one expression, then I click the dropdown menu item to switch to select another item, it will throw exception. I cannot find the root cause.

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            DataTable dt = new DataTable();


            dt.Columns.Add("AA");
            dt.Columns.Add("BB");


            for (int i = 0; i < 10; i++)
            {
                DataRow row = dt.NewRow();
                row["AA"] = "AA" + i.ToString();
                row["BB"] = "BB" + i.ToString();


                dt.Rows.Add(row);
            }


            for (int i = 0; i < 10; i++)
            {
                RadFilterDropDownEditor dropDownFieldEditor = new RadFilterDropDownEditor();
                RadFilter.FieldEditors.Add(dropDownFieldEditor);
                dropDownFieldEditor.DataTextField = "AA";
                //dropDownFieldEditor.DataValueField = "BB";
                dropDownFieldEditor.DataSource = dt;
                dropDownFieldEditor.FieldName = "PV Field:[" + dt.Rows[i]["BB"].ToString() + "]";


                //RadFilterTextFieldEditor textFieldEditor = new RadFilterTextFieldEditor();
                //RadFilter.FieldEditors.Add(textFieldEditor);
                //textFieldEditor.FieldName = "Code Field:[" + dt.Rows[i]["AA"].ToString() + "]";
            }
        }
    }


    protected void RadFilter_FieldEditorCreating(object sender, RadFilterFieldEditorCreatingEventArgs e)
    {
        if (e.EditorType == "RadFilterDropDownEditor")
        {
            e.Editor = new RadFilterDropDownEditor();
        }
    }


    protected void RadButton1_Click(object sender, EventArgs e)
    {
        


    }


    public class RadFilterDropDownEditor : RadFilterDataFieldEditor
    {
        private RadComboBox _combo;


        protected override void CopySettings(RadFilterDataFieldEditor baseEditor)
        {
            base.CopySettings(baseEditor);
            var editor = baseEditor as RadFilterDropDownEditor;
            if (editor != null)
            {
                DataSource = editor.DataSource;
                DataTextField = editor.DataTextField;
                DataValueField = editor.DataValueField;
            }
        }


        public override System.Collections.ArrayList ExtractValues()
        {
            ArrayList list = new ArrayList();
            list.Add(_combo.Text);
            return list;
        }


        public override void InitializeEditor(System.Web.UI.Control container)
        {
            _combo = new RadComboBox();
            _combo.ID = "RadComboBoxField";
            _combo.DataTextField = DataTextField;            
            _combo.DataSource = DataSource;
            _combo.DataBind();
            container.Controls.Add(_combo);
        }


        public override void SetEditorValues(System.Collections.ArrayList values)
        {
            if (values != null && values.Count > 0)
            {
                if (values[0] == null) return;


                _combo.Text = values[0].ToString();
            }
        }




        public string DataTextField
        {
            get
            {
                return (string)ViewState["DataTextField"] ?? string.Empty;
            }
            set
            {
                ViewState["DataTextField"] = value;
            }
        }
        public string DataValueField
        {
            get
            {
                return (string)ViewState["DataValueField"] ?? string.Empty;
            }
            set
            {
                ViewState["DataValueField"] = value;
            }
        }
        public DataTable DataSource
        {
            get
            {
                return (DataTable)ViewState["DataSource"] ?? new DataTable();
            }
            set
            {
                ViewState["DataSource"] = value;
            }
        }
    }
}

Tsvetina
Telerik team
 answered on 11 Sep 2012
13 answers
949 views

I am using telerik grid internal sorting functionality.

 

I have set following properties -

AllowNaturalSort="false"

radGrid.MasterTableView.AllowSorting = true;

 

Issue -

If I click on header text of column, data get sorted but if I try to click on image for sorting, sorting is not working only page get postbacks.

Pavlina
Telerik team
 answered on 11 Sep 2012
1 answer
80 views
I'm getting some really slow performance from one radWindow and normal performance from another that is basically doing the same thing with a similar amount of items? 

They both are loading the same list and one is showing Available and the other Assigned.

Here's what I'm doing:
Grid NeedDataSource Call
1. Load a list from our database
2. Filter data from list and populate a dataset
3. Set dataset as the grid.datasource

I've added debug.writelines to the beginning of both NeedDataSource calls and i'm getting a 12 second lag from the time the Available grid finished to when it starts to work on the Assigned grid? HEre's my output data:

TOP Page_Load 9/11/2012 11:06:01 AM
--- TOP: PopulateRegionFilter() 9/11/2012 11:06:01 AM
--- BOTTOM: PopulateRegionFilter() 9/11/2012 11:06:01 AM
BOTTOM Page_Load 9/11/2012 11:06:01 AM
TOP of  grdAvblServiceAreas_NeedDataSource 9/11/2012 11:06:01 AM
BOTTOM of  grdAvblServiceAreas_NeedDataSource 9/11/2012 11:06:01 AM
TOP of  grdAsgdServiceAreas_NeedDataSource 9/11/2012 11:06:13 AM
BOTTOM of  grdAsgdServiceAreas_NeedDataSource 9/11/2012 11:06:13 AM


Now the crazy thing is that I have another RadWindow using almost the exact same code, but a different list and I'm getting super snappy results?
My parent page is using 2 different RadWindows, is that a problem?
I've been troubleshooting this for a day and half now and I'm completely stuck.
Jay
Top achievements
Rank 1
 answered on 11 Sep 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?