Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
94 views
Hi All,

Not display in date format, what's wrong with follwoing code:

<telerik:GridBoundColumn AllowFiltering="false" DataField="LoggedInFor"
                                            Display="true" HeaderStyle-Width="7%" HeaderText="Last Login"
                                            UniqueName="LoggedIn" DataFormatString="{0:D}">
                                            <HeaderStyle Width="7%" />
                                        </telerik:GridBoundColumn>


or

DataFormatString="{0:MMM/dd/yyyy}"


Thanks & Regards
Amit



Amitkumar
Top achievements
Rank 1
 answered on 24 Dec 2009
1 answer
252 views
Greetings,

I have been struggling a couple of days now with trying to create a grid programmatically with hierarchy using the entity framework and repository pattern.  For example, I am loading Product and Product Details.  I am retrieving my datasource using the entity framework.  See below for code to get Products and Product Details:

public

 

IQueryable<Product> GetProducts()

 

{

 

var products = from p in db.Product.Include("ProductDetail")

 

 

                            select p;

 

 

return products;

 

}

 

public IQueryable<ProductDetail> FindProductDetailsByProduct(Guid productID)

 

{

 

var productDetails = from pd in db.ProductDetail.Include("Product")

 

 

select pd;

 

 

return productDetails.Where(p=> p.Product.ProductID == productID);

 

}

In my codebehind I copied the DefineGridStructure function from the example given in the Grid / Creating Hierarchy Programmatically example:  http://demos.telerik.com/aspnet-ajax/grid/examples/programming/hierarchy/defaultcs.aspx  In this example, it uses a SQLDataSource whereas I'm wanting to bind the data programmatically.  I tried setting the datasource using my GetProducts() function and convert to list and assign to grid.  I have two columns ProductID and ProductName in my Masterview and two columns in my Detailview.  The grid loads and is populate however, when I try to expand, it does not find the relation key (ProductID) of the Masterview.  ProductID is the primary key in my Product table and it is the foreign key in my ProductDetail table.

I am new to using RadGrid and I am not seeing what I am doing wrong.  See actual code below and please point me in the right direction.  If there is an example that uses both programmatic creation  a gird hierarchy and advanced binding I would appreciate if you could forward me the link.  All the samples I have reviewed use on one aspect and I am having trouble putting it all together, including the inserts, updates and deletes.  My business rules are too complex to simply use an entity datasource control.

 

 

private void DefineGridStructure()

 

{

 

RadGrid RadGridProducts = new RadGrid();

 

RadGridProducts.ID =

"RadGridProducts";

 

RadGridProducts.DataSource = GetProductDataSource();

 

RadGridProducts.MasterTableView.DataKeyNames =

new string[] { "ProductID" };

 

RadGridProducts.MasterTableView.Name =

"ProductsView";

 

RadGridProducts.MasterTableView.CommandItemDisplay =

GridCommandItemDisplay.Top;

 

RadGridProducts.Width =

Unit.Percentage(98);

 

RadGridProducts.PageSize = 20;

RadGridProducts.AllowPaging =

true;

 

RadGridProducts.AllowSorting =

true;

 

RadGridProducts.PagerStyle.Mode =

GridPagerMode.NextPrevAndNumeric;

 

RadGridProducts.AutoGenerateColumns =

false;

 

RadGridProducts.ShowStatusBar =

true;

 

RadGridProducts.AllowAutomaticDeletes =

true;

 

RadGridProducts.AllowAutomaticInserts =

true;

 

RadGridProducts.AllowAutomaticUpdates =

true;

 

RadGridProducts.ClientSettings.ClientEvents.OnRowDblClick =

"RowDblClick";

 

 

 

//Register all events for grid

 

 

 

 

 

RadGridProducts.ItemDeleted +=

new GridDeletedEventHandler(RadGridProducts_ItemDeleted);

 

RadGridProducts.ItemInserted +=

new GridInsertedEventHandler(RadGridProducts_ItemInserted);

 

RadGridProducts.ItemUpdated +=

new GridUpdatedEventHandler(RadGridProducts_ItemUpdated);

 

RadGridProducts.InsertCommand +=

new GridCommandEventHandler(RadGridProducts_InsertCommand);

 

RadGridProducts.ItemCommand +=

new GridCommandEventHandler(RadGridProducts_ItemCommand);

 

RadGridProducts.PreRender +=

new EventHandler(RadGridProducts_PreRender);

 

RadGridProducts.NeedDataSource +=

new GridNeedDataSourceEventHandler(RadGridProducts_NeedDataSource);

 

RadGridProducts.DetailTableDataBind +=

new GridDetailTableDataBindEventHandler(RadGridProducts_DetailTableDataBind);

 

RadGridProducts.MasterTableView.PageSize =20;

RadGridProducts.MasterTableView.EditFormSettings.UserControlName =

"~/Controls/Products/ProductDetailsControl.ascx";

 

RadGridProducts.MasterTableView.EditFormSettings.EditFormType =

GridEditFormType.WebUserControl;

 

RadGridProducts.MasterTableView.EditFormSettings.EditColumn.UniqueName =

"EditCommandColumn1";

 

 

//Add columns

 

 

 

 

 

 

GridEditCommandColumn editColumn;

 

editColumn =

new GridEditCommandColumn();

 

editColumn.ButtonType =

GridButtonColumnType.LinkButton;

 

RadGridProducts.MasterTableView.Columns.Add(editColumn);

 

GridBoundColumn boundColumn;

 

boundColumn =

new GridBoundColumn();

 

boundColumn.DataField =

"ProductID";

 

boundColumn.HeaderText =

"Product ID";

 

boundColumn.UniqueName =

"ProductID";

 

boundColumn.Visible =

true;

 

RadGridProducts.MasterTableView.Columns.Add(boundColumn);

boundColumn =

new GridBoundColumn();

 

boundColumn.DataField =

"ProductName";

 

boundColumn.HeaderText =

"Product";

 

RadGridProducts.MasterTableView.Columns.Add(boundColumn);

boundColumn =

new GridBoundColumn();

 

boundColumn.DataField =

"ProductModel";

 

boundColumn.HeaderText =

"Model";

 

RadGridProducts.MasterTableView.Columns.Add(boundColumn);

boundColumn =

new GridBoundColumn();

 

boundColumn.DataField =

"Weight";

 

boundColumn.HeaderText =

"Weight";

 

RadGridProducts.MasterTableView.Columns.Add(boundColumn);

boundColumn =

new GridBoundColumn();

 

boundColumn.DataField =

"Dimensions";

 

boundColumn.HeaderText =

"Dimensions";

 

RadGridProducts.MasterTableView.Columns.Add(boundColumn);

boundColumn =

new GridBoundColumn();

 

boundColumn.DataField =

"SKU";

 

boundColumn.HeaderText =

"SKU";

 

RadGridProducts.MasterTableView.Columns.Add(boundColumn);

 

GridButtonColumn deleteColumn;

 

deleteColumn =

new GridButtonColumn();

 

deleteColumn.ButtonType =

GridButtonColumnType.LinkButton;

 

deleteColumn.CommandName =

"Delete";

 

deleteColumn.Text =

"Delete";

 

deleteColumn.ConfirmText =

"Are you sure you wish to Delete this item?";

 

RadGridProducts.MasterTableView.Columns.Add(deleteColumn);

 

//Detail table - (II in hierarchy level)

 

 

 

 

 

 

GridTableView tableViewProductDetails = new GridTableView(RadGridProducts);

 

tableViewProductDetails.DataSource = GetProductDetailsDataSource();

tableViewProductDetails.DataBind();

tableViewProductDetails.Name =

"ProductDetailsView";

 

tableViewProductDetails.Width =

Unit.Percentage(100);

 

tableViewProductDetails.DataKeyNames =

new string[] { "ProductDetailID" };

 

 

GridRelationFields relationFields = new GridRelationFields();

 

relationFields.MasterKeyField =

"ProductID";

 

relationFields.DetailKeyField =

"ProductID";    /*This line throwing error*/

 

tableViewProductDetails.ParentTableRelation.Add(relationFields);

RadGridProducts.MasterTableView.DetailTables.Add(tableViewProductDetails);

 

//Add columns

 

 

 

 

 

boundColumn =

new GridBoundColumn();

 

boundColumn.DataField =

"ProductDetailID";

 

boundColumn.HeaderText =

"ProductDetailID";

 

boundColumn.UniqueName =

"ProductDetailID";

 

tableViewProductDetails.Columns.Add(boundColumn);

boundColumn =

new GridBoundColumn();

 

boundColumn.DataField =

"MSRP";

 

boundColumn.HeaderText =

"MSRP";

 

tableViewProductDetails.Columns.Add(boundColumn);

 

 

//Add the RadGrid instance to the controls

 

 

 

 

 

 

this.PlaceHolder1.Controls.Add(RadGridProducts);

 

}

Regards,
Fred

Shinu
Top achievements
Rank 2
 answered on 24 Dec 2009
1 answer
172 views
Dear Sir/Madam,

i'm facing a bit problem related to RadGrid.

Explantion-: After filtering the value in RadGrid we can see the filter result after that i open a radwindow for a particular row id .
but when i closed the rad window the filter value of the RadGrid not holding.

Is it possible that we van hold that filter value when return the page.
please let me know it's very urgent..

Thanks & regards
Manoj Kumar Soni
Shinu
Top achievements
Rank 2
 answered on 24 Dec 2009
1 answer
148 views
Hi there,

Has anyone come across the situation where a RadEditor is on a page that is being forced to ssl, and the dialogs open up, but are always blank? It seems the control is creating an iframe to "/controls/RadControls/Editor/Dialog.aspx?dialog=ImageManager&editorID=dnn_ctr474_EditHTML_teContent_teContent&useSession=0&sessionID2=ABCSessionID&language=en_US&UseEmbeddedScripts=yes&tabid=86" which I would assume goes through secure, but it shows up blank, I get the message "Do you want to view only the webpage content that was delivered securely?" if I select no, just goes to the blank popup. If I choose yes, meaning don't send the unsecured content, I get a JavaScript error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 3.0.30618; InfoPath.2; SLCC1)
Timestamp: Wed, 23 Dec 2009 16:34:21 UTC

Message: Object expected
Line: 87
Char: 4

Code: 0
URI: https://www.TestSite.com/controls/RadControls/Editor/Dialog.aspx?dialog=ImageManager&editorID=dnn_ctr474_EditHTML_teContent_teContent&useSession=0&sessionID2=ABCSessionID&language=en_US&UseEmbeddedScripts=yes&tabid=86

 

Is this an issue you've seen?  Any help would be so greatly appreciated as we use the RadControls extensively and absolutely love them.

Regards,

Marco Andrade


Rumen
Telerik team
 answered on 24 Dec 2009
6 answers
129 views
Good day!

I'm trying to follow the online demos on a current project using the RadScheduler, but it seems that the Description field for the Appointment is missing. Was it removed on purpose on the latest version of the RadControls?

Thank you very much.
Joe Buckle
Top achievements
Rank 1
 answered on 24 Dec 2009
2 answers
153 views
Hi,
I am creating a radgrid, specifying the PageSize=20 and setting the PagerStyle Mode=NextPrevNumericAndAdvanced

 

 

Then, when I have less than 20 rows, no paging controls are displayed, that's fine.
But if I have 25 records it shows me the text box, where customer can specify desired page size. Ok.
If he specify here 30, nothing will change, page size will remain 20. Yes. if he sets page size to 25, all the records will be displayed and paging control disappears. I belive that should happed by default if he specify page size more than records in the grid.
Why it keeps the current page size instead of taking the max number of records as new value?
Am I missing some scenarios where it could be misleading?

Thank you,
Alex.

Princy
Top achievements
Rank 2
 answered on 24 Dec 2009
1 answer
133 views
I have an radcombobox with an autosuggest,
If no suggestions are found, than the dropdown with the suggestions doesn't close.
Is there anyway to do this?
Shinu
Top achievements
Rank 2
 answered on 24 Dec 2009
1 answer
685 views

Since I'm not familiar with everything RadGrid and RadWindow can do, I'm wondering if I'm re-inventing the wheel and these controls already do some of this, or something similar.

I have some pretty static data I don't want to query often to save trips. So I thought I'd have the Cache hold the data until 20 minutes after it's no longer requested. (It seems to work, but I've never used the Cache before, so I'm not sure of the pros and cons.) Anyway, I have a RadGrid on an aspx page. Below is the example code behind against the Northwind DB. The aspx page is referenced by a RadWindow that makes it popup modally.

Like I said, I'm wondering if I'm doing more than necessary, or if I'm doing some bad/inefficient coding in regard to your controls, or even in general. Thanks for any input you can give.


Imports System.Data  
 
Partial Class MyRadGrid  
    Inherits System.Web.UI.Page  
 
    Protected Sub RadGrid1_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource  
 
        Dim strSQL As String 
        strSQL = "SELECT SupplierID, ContactName, City, Region, PostalCode, Country FROM Suppliers" 
 
        Dim strCacheName As String = "SupplierData" 
        Dim ds As DataSet = CType(Cache(strCacheName), DataSet)  
 
        If ds Is Nothing Then 
            Dim aDB As New AccessDataSource("~/App_Data/Northwind.mdb", strSQL)  
            Dim mydv As System.Data.DataView = CType(aDB.Select(DataSourceSelectArguments.Empty), System.Data.DataView)  
            Dim dt As DataTable = mydv.ToTable  
            ds = New DataSet  
            ds.Tables.Add(dt)  
            Cache.Insert(strCacheName, ds, Nothing, Cache.NoAbsoluteExpiration, New System.TimeSpan(0, 0, 20))  
        End If 
 
        RadGrid1.DataSource = ds  
 
    End Sub 
 
End Class 
 
Princy
Top achievements
Rank 2
 answered on 24 Dec 2009
1 answer
73 views

I've placed a grid into a RadWindow. It looks great and I love the functionality. However, If I do a filter and the resulting data is small (say only 2 rows) then when I click on the filter again, the filter options are cut off inside the window. It prevents me from turning the filter off or looking at other options, forcing me to close the window. I assume there's a way around this?

Princy
Top achievements
Rank 2
 answered on 24 Dec 2009
0 answers
125 views
This post was removed.
Giang Dinh
Top achievements
Rank 1
 asked on 24 Dec 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
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
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?