Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
123 views
Hi!

I tried to create a sample program which is able to filter items in an rad grid in google auto suggest style. My problem is that the ItemsRequested mehtod of the radcombobox is never fired. So i tried to add values in the box during creation, this works ok but if i click one item in the list it happens nothing. If i add no value in the box, it shows loading when i click in the RadComboxBox and nothing happens, i does not even fire a postback event.

Ajax Settings
<asp:ScriptManager ID="ScriptManager" runat="server" /> 
    <radg:RadAjaxManager ID="AjaxManager" runat="server"
        <AjaxSettings> 
            <radg:AjaxSetting AjaxControlID="RadGrid1"
                <UpdatedControls> 
                    <radg:AjaxUpdatedControl ControlID="RadGrid1" /> 
                </UpdatedControls> 
            </radg:AjaxSetting> 
        </AjaxSettings> 
    </radg:RadAjaxManager> 

Grid Declaration

<radg:radgrid id="RadGrid1" runat="server" autogeneratecolumns="False" 
            allowsorting="True" allowfilteringbycolumn="True" width="1024px"  
            Height="800px" skin="Telerik"  
             onitemcommand="RadGrid1_ItemCommand"  
            onneeddatasource="RadGrid1_NeedDataSource">   
                <MasterTableView AllowFilteringByColumn="True" />  
                <PagerStyle Mode="NumericPages" />  
                <ClientSettings> 
                    <Scrolling AllowScroll="true" /> 
                </ClientSettings> 
            </radg:radgrid> 

CustomFIlter Class

public class MyCustomFilteringColumn : GridBoundColumn 
    { 
        public MyCustomFilteringColumn() { } 
        public MyCustomFilteringColumn(string dataFieldName, string headerText) 
        { 
            this.DataField = dataFieldName; 
            this.HeaderText = headerText; 
        } 
 
        public static string connectionString 
        { 
            get 
            { 
                string dbPath = System.Web.HttpContext.Current.Server.MapPath("~\\Nwind.mdb"); 
                return ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + dbPath); 
            } 
        } 
 
        protected override void SetupFilterControls(TableCell cell) 
        { 
            base.SetupFilterControls(cell); 
            cell.Controls.RemoveAt(0); 
            RadComboBox combo = new RadComboBox(); 
            combo.ID = ("RadComboBox1" + this.DataField); 
            combo.ShowToggleImage = false
            combo.Skin = "Telerik"
            combo.EnableLoadOnDemand = true
            combo.AutoPostBack = true
            combo.MarkFirstMatch = true
            combo.Height = Unit.Pixel(100); 
            combo.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(this.list_ItemsRequested); 
            combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(this.list_SelectedIndexChanged); 
            cell.Controls.AddAt(0, combo); 
 
 
 
            List<ConfigurationInformation> infos = (List<ConfigurationInformation>)this.Owner.DataSource; 
 
            List<string> listsource = new List<string>(); 
 
            foreach (ConfigurationInformation info in infos) 
            { 
                if (this.DataField == "City"
                    listsource.Add(info.City); 
                else if (this.DataField == "CustomerName"
                    listsource.Add(info.CustomerName); 
                else if (this.DataField == "Country"
                    listsource.Add(info.Country); 
                else if (this.DataField == "OrderDate"
                    listsource.Add(info.OrderDate.ToString()); 
            } 
            combo.DataSource = listsource; 
            cell.Controls.RemoveAt(1); 
        } 
 
        protected override void SetCurrentFilterValueToControl(TableCell cell) 
        { 
            base.SetCurrentFilterValueToControl(cell); 
            RadComboBox combo = (RadComboBox)cell.Controls[0]; 
            if (this.CurrentFilterValue != string.Empty) 
            { 
                combo.Text = this.CurrentFilterValue; 
            } 
        } 
 
        protected override string GetCurrentFilterValueFromControl(TableCell cell) 
        { 
            RadComboBox combo = (RadComboBox)cell.Controls[0]; 
            return combo.Text; 
        } 
 
        private void list_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) 
        { 
            (o as RadComboBox).DataTextField = this.DataField; 
            (o as RadComboBox).DataValueField = this.DataField; 
 
            if (((RadComboBox)o).DataTextField == "CustomerName"
            { 
                List<ConfigurationInformation> test = (List<ConfigurationInformation>)this.Owner.DataSource; 
                (o as RadComboBox).DataSource = test.Distinct<ConfigurationInformation>(new CustomerNameComparer()); 
                /*this.Owner.DataSource*/ 
            } 
            else 
                (o as RadComboBox).DataSource = GetDataTable("SELECT DISTINCT " + this.UniqueName + " FROM Customers WHERE " + this.UniqueName + " LIKE '" + e.Text + "%'"); 
             
            (o as RadComboBox).DataBind(); 
        } 
 
        private void list_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
        { 
            GridFilteringItem filterItem = (GridFilteringItem)(o as RadComboBox).NamingContainer; 
            if (this.UniqueName == "Index"
            { 
                filterItem.FireCommandEvent("Filter"new Pair("EqualTo"this.UniqueName)); 
            } 
            filterItem.FireCommandEvent("Filter"new Pair("Contains"this.UniqueName)); 
        } 
 
        public static DataTable GetDataTable(string query) 
        { 
            OleDbConnection MyOleDbConnection = new OleDbConnection(connectionString); 
            OleDbDataAdapter MyOleDbDataAdapter = new OleDbDataAdapter(); 
            MyOleDbDataAdapter.SelectCommand = new OleDbCommand(query, MyOleDbConnection); 
            DataTable myDataTable = new DataTable(); 
            MyOleDbConnection.Open(); 
            try 
            { 
                MyOleDbDataAdapter.Fill(myDataTable); 
            } 
            finally 
            { 
                MyOleDbConnection.Close(); 
            } 
            return myDataTable; 
        } 
    } 

Default.aspx Code File

 private List<ConfigurationInformation> Configs = new List<ConfigurationInformation>(); 
         
        public static string connectionString 
        { 
            get 
            { 
                string dbPath = System.Web.HttpContext.Current.Server.MapPath("~\\Nwind.mdb"); 
                return ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + dbPath); 
            } 
        } 
 
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
        { 
            RadGrid1.DataSource = Configs; 
            //Configs.Distinct(new CustomerNameComparer()); 
        } 
 
        protected void Page_Load(object sender, System.EventArgs e) 
        { 
            if (!IsPostBack) 
            { 
                DataTable dt2 = GetDataTable("SELECT Customers.ContactName as CustomerName, Customers.City, Customers.Country, Orders.OrderDate FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID where Index < 10;"); 
                foreach (DataRow row in dt2.Rows) 
                    Configs.Add(new ConfigurationInformation( 
                        (string)row["CustomerName"], (string)row["Country"], (string)row["City"], (DateTime)row["OrderDate"])); 
 
                //ds = GetDataSet("SELECT Country, City, Index FROM Customers"); 
                this.RadGrid1.MasterTableView.Columns.Clear(); 
 
                this.RadGrid1.MasterTableView.Columns.Add(new MyCustomFilteringColumn("CustomerName""Customer Name")); 
                this.RadGrid1.MasterTableView.Columns.Add(new MyCustomFilteringColumn("City""City")); 
                this.RadGrid1.MasterTableView.Columns.Add(new MyCustomFilteringColumn("Country""Country")); 
                this.RadGrid1.MasterTableView.Columns.Add(new MyCustomFilteringColumn("OrderDate""Order Date")); 
            } 
        } 
 
        //protected void RadGrid1_ColumnCreating(object sender, GridColumnCreatingEventArgs e) 
        //{ 
        //    if (e.ColumnType == typeof(MyCustomFilteringColumn).Name) 
        //    { 
        //        e.Column = new MyCustomFilteringColumn(); 
        //    } 
        //} 
 
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == "Filter"
            { 
                foreach (GridColumn column in e.Item.OwnerTableView.Columns) 
                { 
                    column.CurrentFilterValue = string.Empty; 
                    column.CurrentFilterFunction = GridKnownFunction.NoFilter; 
                } 
            } 
        } 
 
        protected void clrFilters_Click(object sender, System.EventArgs e) 
        { 
            foreach (GridColumn column in RadGrid1.MasterTableView.Columns) 
            { 
                column.CurrentFilterFunction = GridKnownFunction.NoFilter; 
                column.CurrentFilterValue = string.Empty; 
            } 
            RadGrid1.MasterTableView.FilterExpression = string.Empty; 
            RadGrid1.MasterTableView.Rebind(); 
        } 
 
        public static DataTable GetDataTable(string query) 
        { 
            OleDbConnection MyOleDbConnection = new OleDbConnection(connectionString); 
            OleDbDataAdapter MyOleDbDataAdapter = new OleDbDataAdapter(); 
            MyOleDbDataAdapter.SelectCommand = new OleDbCommand(query, MyOleDbConnection); 
            DataTable myDataTable = new DataTable(); 
            MyOleDbConnection.Open(); 
            try 
            { 
                MyOleDbDataAdapter.Fill(myDataTable); 
            } 
            finally 
            { 
                MyOleDbConnection.Close(); 
            } 
            return myDataTable; 
        } 
 
        //public static DataSet GetDataSet(string query) 
        //{ 
        //    OleDbConnection MyOleDbConnection = new OleDbConnection(connectionString); 
        //    OleDbDataAdapter MyOleDbDataAdapter = new OleDbDataAdapter(); 
        //    MyOleDbDataAdapter.SelectCommand = new OleDbCommand(query, MyOleDbConnection); 
        //    DataSet myDataSet = new DataSet("Customers"); 
        //    MyOleDbConnection.Open(); 
        //    try 
        //    { 
        //        MyOleDbDataAdapter.Fill(myDataSet); 
        //    } 
        //    finally 
        //    { 
        //        MyOleDbConnection.Close(); 
        //    } 
        //    return myDataSet; 
        //} 
    } 

Can you please help me to get the event fired? I also have a second question regarding the ColumnCreating event, is it nessercery to implement that event and what funcionality is required in there?

greetings
Martin


Nikolay Rusev
Telerik team
 answered on 20 Feb 2009
3 answers
132 views
We purchased the Telerik UI suite (RadControls for ASP.NET AJAX) with source code.

We want to add our own source code files to the Telerik code and reference our own assemblies in the new build.

1) We are not able to compile Telerik.Web.UI using Nant after performing above as suggested in Command Prompt
2) There is no log file available for NAnt Build to check the errors in the build.
2) If we do not use NAnt, we are able to build in VS 2005 in release mode but when assembly is used it generates the error:

Assembly 'Telerik.Web.UI, Version=2008.2.1001.0, Culture=neutral, PublicKeyToken=29ac1a93ec063d92' contains a Web resource with name 'Telerik.Web.UI.Grid.RadGridScripts.js', but does not contain an embedded resource with name 'Telerik.Web.UI.Grid.RadGridScripts.js'.


Further on adding above required file in Grid folder, changing the properties of js file to Compile, then the project does not build only.
3) Also, when the assemblies we get after building in release mode in VS 2005 are used in an application, they go into source code of Telerik.Web.UI despite of being built in Release mode.This behavious is not desirable.

Please suggest the solution to above:
1) Either how to go forward using NAnt Build? or
2) How to build in Release mode in VS 2005 without above problems?

Please mark a copy of reply to:
-chetan.mehta@cognizant.com
-rohit.virmani@cognizant.com

Regards
Chetan
Frameworks Team
marketRx (A Cognizant company)



Atanas Korchev
Telerik team
 answered on 20 Feb 2009
1 answer
414 views
Hi All,
I have an web application where in i am using a master page and all the pages uses this master page. All the content pages have <form runat=server> tag and other controls in the form.

Now I want to use rad menu in top section of master page and I am not able to since I need to use scriptmanager and this needs to be under <form runat=server> tag too and all the content pages start in mid section. How can i implement this without changing the content pages.

Appreciate an early response.
Thanks
Laxman
Paul
Telerik team
 answered on 20 Feb 2009
1 answer
91 views

When attempting to use the slider control with paging the code gets an invalid object error at the following point:

 

if(this._showDragHandle){

if(_64){

_63.style.left=_6e.x+"px";

}else{

_63.style.top=_6e.y+"px";

}

 


I've tried switching skins but it makes no difference.

Thanks in advance for any help/advice.
Yavor
Telerik team
 answered on 20 Feb 2009
2 answers
183 views
Hi,

I hav a template column and i need to hide it on the databound event when a specified condition is satisfied...

and hav to make it visible when not satisfied..

plz help me..

thanks...
Priya
Top achievements
Rank 1
 answered on 20 Feb 2009
1 answer
62 views
Hi Team,
           I have to implement the drag & drop feature between two tree view control . I have to drop in the tree view control in such a manner so that the drop node should not become a parent node , it should always be a childnode . I have implemented the Load On Demand feature.  How can I achive this ? Help me out .

Regards
Manoj
Shinu
Top achievements
Rank 2
 answered on 20 Feb 2009
2 answers
146 views
Hi,

I want to hide the expand/collapse images in hierarchical radgird when there are no records, i tried the method provided in the help link but that's not working for me it hides all the expand/collapse buttons independent of wheather the records is there or not.

http://www.telerik.com/help/aspnet-ajax/grdhideexpandcollapseimageswhennorecords.html

I am building 3 levele hierarchical grid, manually i am building the tables and setting and binding the datasource at the server. kindly advise how to hide expand/collapse images in my case, Thanks in advance. below is my code.

 

<telerik:RadTabStrip ID="radtabstpPatientView" SelectedIndex="0" runat="server" MultiPageID="radmltpgPatientView"

 

 

Skin="CustomTabStripSkin" CssClass="clsLabel" EnableEmbeddedSkins="false" >

 

 

<Tabs>

 

 

<telerik:RadTab Text="Patient Chronology" PageViewID="PatChronology">

 

 

</telerik:RadTab>

 

 

</Tabs>

 

 

<Tabs>

 

 

<telerik:RadTab Text="Balance Summary" PageViewID="BalSummary">

 

 

</telerik:RadTab>

 

 

</Tabs>

 

 

<Tabs>

 

 

<telerik:RadTab Text="Unapplied Payment Details" PageViewID="UnappliedPayDet">

 

 

</telerik:RadTab>

 

 

</Tabs>

 

 

</telerik:RadTabStrip>

 

 

<telerik:RadMultiPage ID="radmltpgPatientView" runat="server" SelectedIndex="0" CssClass="clsLabel">

 

 

<telerik:RadPageView ID="radpgviewPatChronology" runat="server">

 

 

<table border="0" cellpadding="2" cellspacing="2" width="100%">

 

 

<tr>

 

 

<td>

 

 

<telerik:RadGrid ID="RadGrid1" Skin="Office2007" runat="server" Width="95%" AutoGenerateColumns="False"

 

 

PageSize="7" AllowSorting="True" AllowPaging="True" GridLines="None" ShowStatusBar="true" AllowMultiRowSelection="true" >

 

 

<PagerStyle Mode="NumericPages"></PagerStyle>

 

 

<MasterTableView AllowMultiColumnSorting="True" DataKeyNames="dt1Id,Type" Width="100%" EnableNoRecordsTemplate="false" >

 

 

<Columns>

 

 

<telerik:GridBoundColumn SortExpression="dt1Id" HeaderText="DTID" HeaderButtonType="TextButton"

 

 

DataField="dt1Id" Resizable="True" Reorderable="True" Display="false">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn SortExpression="Type" HeaderText="Type" HeaderButtonType="TextButton"

 

 

DataField="Type" Resizable="True" Reorderable="True">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn SortExpression="Date" HeaderText="Date" HeaderButtonType="TextButton"

 

 

DataField="Date" Resizable="True" Reorderable="True">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn SortExpression="Description" HeaderText="Description" HeaderButtonType="TextButton"

 

 

DataField="Description" Resizable="True" Reorderable="True">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

<DetailTables >

 

 

<telerik:GridTableView Caption="" AllowSorting="false" DataKeyNames="dt1Id" Width="100%" ShowHeader="false" EnableNoRecordsTemplate="false">

 

 

<ParentTableRelation>

 

 

<telerik:GridRelationFields DetailKeyField="dt1Id" MasterKeyField="dt1Id" />

 

 

</ParentTableRelation>

 

 

<Columns>

 

 

<telerik:GridBoundColumn HeaderText="dt1Id" HeaderButtonType="TextButton"

 

 

DataField="dt1Id" Display="false">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Type" HeaderButtonType="TextButton"

 

 

DataField="Type">

 

 

<ItemStyle Width="207px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Date" HeaderButtonType="TextButton"

 

 

DataField="Date">

 

 

<ItemStyle Width="67px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn HeaderText="">

 

 

<ItemTemplate>

 

 

<asp:ImageButton id="imgbtn" imageurl="~/Images/btn_Edit.gif" runat="server" visible= <%# DataBinder.Eval(Container.DataItem, "Status")%>>

 

 

</asp:ImageButton>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn HeaderText="Description" HeaderButtonType="TextButton"

 

 

DataField="Description">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

<DetailTables>

 

 

<telerik:GridTableView Caption="" AllowSorting="false" DataKeyNames="dt1Id" Width="100%" ShowHeader="false" EnableNoRecordsTemplate="false" >

 

 

<ParentTableRelation>

 

 

<telerik:GridRelationFields DetailKeyField="dt1Id" MasterKeyField="dt1Id" />

 

 

</ParentTableRelation>

 

 

<Columns>

 

 

<telerik:GridBoundColumn HeaderText="dt1Id" HeaderButtonType="TextButton"

 

 

DataField="dt1Id" Display="false">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Type" HeaderButtonType="TextButton"

 

 

DataField="Type">

 

 

<ItemStyle Width="207px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Date" HeaderButtonType="TextButton"

 

 

DataField="Date">

 

 

<ItemStyle Width="67px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn HeaderText="">

 

 

<ItemTemplate>

 

 

<asp:ImageButton id="imgbtn" imageurl="~/Images/btn_Edit.gif" runat="server" visible= <%# DataBinder.Eval(Container.DataItem, "Status")%>>

 

 

</asp:ImageButton>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn HeaderText="Description" HeaderButtonType="TextButton"

 

 

DataField="Description">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

</telerik:GridTableView>

 

 

</DetailTables>

 

 

</telerik:GridTableView>

 

 

</DetailTables>

 

 

</MasterTableView>

 

 

<ClientSettings>

 

 

<Selecting AllowRowSelect="true" />

 

 

</ClientSettings>

 

 

</telerik:RadGrid>


This is the way iam setting and bindiing the datasoruce for the grid

RadGrid1.MasterTableView.DataSource = dtTable1

 

RadGrid1.MasterTableView.DetailTables(0).DataSource = dtTable2

RadGrid1.MasterTableView.DetailTables(0).DetailTables(0).DataSource = dtTable3

RadGrid1.DataBind()


The table structures are as below

 

dtTable1.Columns.Add(

"dt1Id")

 

dtTable1.Columns.Add(

"Type")

 

dtTable1.Columns.Add(

"Date")

 

dtTable1.Columns.Add(

"EmptyColumn")

 

dtTable1.Columns.Add(

"Description")

 

dtTable1.Columns.Add(

"Status")

 

dtTable2.Columns.Add(

"dt1Id")

 

dtTable2.Columns.Add(

"Type")

 

dtTable2.Columns.Add(

"Date")

 

dtTable2.Columns.Add(

"EmptyColumn")

 

dtTable2.Columns.Add(

"Description")

 

dtTable2.Columns.Add(

"Status")

 

dtTable3.Columns.Add(

"dt1Id")

 

dtTable3.Columns.Add(

"Type")

 

dtTable3.Columns.Add(

"Date")

 

dtTable3.Columns.Add(

"EmptyColumn")

 

dtTable3.Columns.Add(

"Description")

 

dtTable3.Columns.Add(

"Status")

Regards,

Santhosh

 

santhosh
Top achievements
Rank 2
 answered on 20 Feb 2009
1 answer
119 views
Hi,
radcombobox selectedindexchanged fired two times. How to solve this?

Thanks

Mamun
Shinu
Top achievements
Rank 2
 answered on 20 Feb 2009
3 answers
71 views

I'm trying to create an instance of the client side object for a panelbar and it keeps telling me that the method does not exist.  I'm using the following code.

                var panelbar = $find("<%=RadPanelBar1.ClientID%>");
                var item = panelbar._findItemByText("PATIENT IS GOOD MATCH");
                item.set_text("New Text");


<cc1:RadPanelBar ID="RadPanelBar1" runat="server" Skin="WebBlue"
            Width="500px" ExpandMode="SingleExpandedItem" style="text-align: left;">
            <ExpandAnimation Type="OutQuint" Duration="400" />
            <CollapseAnimation Type="OutQuint" Duration="300" />
            
            <Items>
            
                <cc1:RadPanelItem runat="server" Text="PATIENT IS GOOD MATCH" />

.........



thanks for you help,

Ben
Paul
Telerik team
 answered on 20 Feb 2009
1 answer
159 views
Hi,
How do I get the decimal separator to appear in x-axis values. eg. '10,000'?
thanks

PS. Your help here really is poor. See:
ms-help://telerik.aspnetajax.radcontrols.2008.Q3/telerik.aspnetajax.radcontrols.api.2008.Q3/Telerik.Web.UI~Telerik.Charting.Styles.ChartValueFormat.html

I should not have to try every variant.

I note number puts in the thousand separatot, but it puts unecessary values after the decimal seperator. EG. 10,000.000
I just want 10,000
Ves
Telerik team
 answered on 20 Feb 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?