Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
88 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
84 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
179 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
53 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
970 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
84 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
13 answers
3.9K+ views
Hello,

can you help me find resolve my following problem..?

I have RadGrid with Numeric Columns and one GridButtonColumn for automatic deletes. This is markup of one of my columns:

<telerik:GridNumericColumn DataField="HoursAmount" HeaderText="hrs." DataFormatString="{0:### ##0.0}"
  ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" />

When I click on delete link on column where value is bigger then 1000, grid write this error: Failed to set one or more properties on type Arcon.Web.ServiceJobHour. 1 000,00 is not a valid value for Decimal.

Now I'm finding way to use DecimalDigits property of GridNumericColumn but this doesn't do anything...

<telerik:GridNumericColumn DataField="HoursAmount" HeaderText="hrs." DataFormatString="{0:### ##0.0}"
  ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right"  DecimalDigits="2" />

Can you help me find to resolve it?

Thanks
Kavitha
Top achievements
Rank 1
 answered on 11 Sep 2012
4 answers
85 views
Hello,

I have an MVC 3.0 project which uses a Telerik MVC editor, for which we wanted to add spell checking.  Since MVC doesn't include RadSpell, I followed the instructions on these forums and elsewhere to integrate the Asp.Net AJAX spell check control.

From my Razor view I render a partial ascx view with the spell check control, and add a custom tool to the editor which calls this control via javascript.  The Javascript function finds the spell check control, sets it's controltocheck property to the appropriate value, and then starts the spell checking.

This works great in IE8, however in Chrome or Firefox it fails because the command I use to find the control returns null in those browsers (BUT finds the correct control in IE).

function checkSpelling(id) {
    var spell = $telerik.findSpell('<%= RadSpell1.ClientID %>');
    spell.set_controlToCheck(id+"Iframe");
    spell.startSpellCheck();
}


I've attached a small demo project that shows this problem.  I've seen some suggestions that this maybe a timing issue with the function running before the control is initialized, though this seems unlikely, and besides the suggested solutions to that (e.g. Sys.Application.add_load()  don't fix the issue. Please help me resolve this problem.
Martha
Top achievements
Rank 1
 answered on 11 Sep 2012
3 answers
32 views
HI,

I am using Telerik Rad Spliiter with Rad Tree control inside (Web Application has simple web page withh Rad splitter and tree with 10 nodes).

Sometimes on slower network and from remote location , page is not displayed (nont rendered completely). However if i just click on intenet explorer maximum button and all is visible(rendered). This is a random behaviour and is not reproducable  always and from all locations/networks.

I have noticed that this is a behavior specific to pages where we have RadSplitter control.  I tried to repaint the  Radspliter contol but no luck.

Please suggest.

Thanks and regards,
Manishkumar Patel

Vessy
Telerik team
 answered on 11 Sep 2012
1 answer
231 views
Hello, 

I have a grid that loads the data through a web-service. This is my code:

Grid:
<telerik:RadGrid runat="server" ID="rgOverzicht" Width="690px" PageSize="10"
                AllowPaging="true" AllowSorting="false" ClientSettings-Scrolling-AllowScroll="false" ClientSettings-Scrolling-UseStaticHeaders="true" AllowFilteringByColumn="false" AllowMultiRowSelection="false" EnableLinqExpressions="false">
                <GroupingSettings CaseSensitive="false" />
                <MasterTableView NoMasterRecordsText="Geen artikelen om te tonen." DataKeyNames="Artikel_Id" ClientDataKeyNames="Artikel_Id" TableLayout="Fixed">
                    <PagerStyle Mode="NextPrevAndNumeric" PagerTextFormat="<b>{4}</b>  Pagina <b>{0}</b> van <b>{1}</b> | Item <b>{2}</b> t/m <b>{3}</b> van de <b>{5}</b>. " ShowPagerText="True" />
                    <Columns>
                        <telerik:GridBoundColumn DataField="IndexNr" UniqueName="IndexNr" HeaderText="Index" HeaderStyle-Width="65px"  />
                        <telerik:GridBoundColumn DataField="Omschrijving" UniqueName="Omschrijving" HeaderText="Omschrijving" />
                        <telerik:GridBoundColumn DataField="Afmeting" UniqueName="Afmeting" HeaderText="Afmeting" HeaderStyle-Width="65px"  />
                        <telerik:GridBoundColumn DataField="Drukklasse" UniqueName="Drukklasse" HeaderText="Drukklasse" HeaderStyle-Width="65px"  />
                        <telerik:GridBoundColumn DataField="Eenheidstarief" UniqueName="Eenheidstarief" HeaderText="Prijs (in €)" HeaderStyle-Width="75px"  />
                    </Columns>
                    <PagerStyle Mode="NumericPages" />
                </MasterTableView>
                <ClientSettings EnableRowHoverStyle="true">
                    <DataBinding SelectMethod="GetDataAndCount"
                    Location="~/CalculatieGrid.asmx"
                        SortParameterType="Linq" FilterParameterType="Linq" >
                    </DataBinding>
                    <Selecting AllowRowSelect="True" />
                </ClientSettings>
            </telerik:RadGrid>

Web-service:
var data = RadGrid.GetBindingData(source, startRowIndex, maximumRows, sortExpression, filterExpression);
 
result.Data = data.Data.ToList();
result.Count = data.Count;
 
return result;

JavaScript filter function:
<script type="text/javascript">
                $("#Search").click(function (e) {
                    if ($('#txtFilterOmschrijving').val() != "" && $('#txtFilterOmschrijving').val() != $('#txtFilterOmschrijving').attr("defaultValue")) {
                        filterExpression = new Telerik.Web.UI.GridFilterExpression();
                        filterExpression.set_fieldName("Omschrijving");
                        filterExpression.set_columnUniqueName("Omschrijving");
                        filterExpression.set_dataTypeName("System.String");
                        filterExpression.set_filterFunction(Telerik.Web.UI.GridFilterFunction.Contains);
                        ItemIdentifier = $('#txtFilterOmschrijving').val();
                        filterExpression.set_fieldValue(ItemIdentifier);
 
                        vFilterExpressions.add(filterExpression);
                    }
                    tableView.rebind();
                    tableViewPlan.rebind();
                });
            </script>

The problem is that the filters are case sensitive. I tried setting the case sensitive option in groupsettings in the grid, but that has no effect. Does anyone have a solution?

Thanks in advance!
Tsvetina
Telerik team
 answered on 11 Sep 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
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
Iron
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?