<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridClientDeleteColumn
CommandName
=
"Delete"
ButtonType
=
"LinkButton"
></
telerik:GridClientDeleteColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnCommand
=
"OnCommand"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
function
OnCommand(sender, args) {
}
Private
Function
SomeTable()
As
DataTable
Dim
dt
As
New
DataTable()
dt.Columns.Add(
New
DataColumn(
"FieldName"
, Type.
GetType
(
"System.String"
)))
row(
"FieldName"
) =
"C:\SomeDirectory\RadGridExport.pdf"
dt.Rows.Add(row)
Return
dt
End
Function
<
telerik:GridAttachmentColumn
DataSourceID
=
"ObjectDataSource1"
HeaderText
=
"Attachment Column"
AttachmentKeyFields
=
"FieldName"
AttachmentDataField
=
"FieldName"
DataTextField
=
"FieldName"
UniqueName
=
"FieldName"
ButtonType
=
"ImageButton"
UploadControlType
=
"RadAsyncUpload"
FileName
=
"RadGridExport.pdf"
ImageUrl
=
"pdf-icon.png"
ItemStyle-Height
=
"36px"
ItemStyle-Width
=
"36px"
>
</
telerik:GridAttachmentColumn
>
<
asp:ObjectDataSource
ID
=
"ObjectDataSource1"
runat
=
"server"
SelectMethod
=
"MySelectMethod"
TypeName
=
"MyApp"
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"FieldName"
Type
=
"String"
/>
</
SelectParameters
>
</
asp:ObjectDataSource
>
Public
Class
MyApp
<DataObjectMethodAttribute(DataObjectMethodType.
Select
,
True
)>
Public
Function
MySelectMethod(filePath
As
String
)
As
DataTable
Dim
dt
As
New
DataTable(
"Base"
)
Dim
col
As
New
DataColumn(
"FieldName"
)
col.DataType = System.Type.
GetType
(
"System.Byte[]"
)
dt.Columns.Add(col)
Dim
row
As
DataRow = dt.NewRow
row(0) = My.Computer.FileSystem.ReadAllBytes(filePath)
dt.Rows.Add(row)
Return
dt
End
Function
End
Class
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"true"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
ExportSettings
ExportOnlyData
=
"true"
>
<
Excel
Format
=
"Biff"
/>
</
ExportSettings
>
<
MasterTableView
Caption
=
"My Personalized caption"
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ShowExportToExcelButton
=
"true"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = OrdersTable();
}
private
DataTable OrdersTable()
{
DataTable dt =
new
DataTable();
dt.Columns.Add(
new
DataColumn(
"OrderID"
,
typeof
(
int
)));
dt.Columns.Add(
new
DataColumn(
"OrderDate"
,
typeof
(DateTime)));
dt.Columns.Add(
new
DataColumn(
"Freight"
,
typeof
(
decimal
)));
dt.Columns.Add(
new
DataColumn(
"ShipName"
,
typeof
(
string
)));
dt.Columns.Add(
new
DataColumn(
"ShipCountry"
,
typeof
(
string
)));
dt.PrimaryKey =
new
DataColumn[] { dt.Columns[
"OrderID"
] };
return
dt;
}
System.ArgumentOutOfRangeException
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
This error seems to happen if there is a GridTemplateColumn that has the Exportable property set to False.
Hi
Since updating to the latest release of UI for ASP.NET AJAY the RadContextMenu of my RadGrid is misaligned at the right edge of the screen. Even in your sample https://demos.telerik.com/aspnet-ajax/grid/examples/columns-rows/columns/context-menu/defaultcs.aspx when you open the context menu at the right side of the screen the context menu is nor aligned to the left (like it used to be).
Please ses the attached printscreen.
Kind regards
Felix
In GridTableView.cs, you provide a function protected virtual GridTableView CreateTableView() (Line 7828). This function can be overloaded to return derived classes from GridTableView. But, this is not overloadable completely. Because you create a GridTableView directly in protected void BuildDetailTablesFromDataSource() (Line 8808), too. There you would have to call a virtual creator function, too. This is necessary, because I have a lot of Trouble with your DataBind which I was able to fix with an overload. It is much to hard to make this bug visible for you, I really tried to do so already, but I had to fix this that way, because your GridTableView without my derivation fails in our szenario. The call stack for that problem, I'd had to fix, is always like: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IndexOutOfRangeException: Cannot find column CheckSum. at System.Data.DataTable.ParseSortString(String sortString) at System.Data.DataView.set_Sort(String value) at Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() at Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() at Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray, Boolean shouldClearDataKeys) at Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) at Telerik.Web.UI.GridTableView.PerformSelect() at Telerik.Web.UI.GridTableView.DataBind() at Telerik.Web.UI.GridItemBuilder.BindDetailTable(GridDataItem parentItem, GridTableView cloned) at Telerik.Web.UI.GridItemBuilder.BindDetailTables(GridDataItem parentItem, GridNestedViewItem detailItem) at Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) at Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) at Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) at Telerik.Web.UI.GridTableView.PerformSelect() at Telerik.Web.UI.GridTableView.DataBind() In that, your DataTableView gets an invalid sort Expression string. Therefore, I overwrote DataBind. But this is not possible in all cases, if you create GridViewTable() objects on your own. Best regards
Images that reside in the grid will get resized (scaled down with about 3-5 %) which might cause issues, specially if exporting bar-codes, thus the bar-code scanners won't be able to read them. Current workaround is to use the Telerik Documents Processing Library and build the table manually where the images are inserted without changing the size. Here is an example: protected void RadGrid1_InfrastructureExporting(object sender, GridInfrastructureExportingEventArgs e) { Telerik.Web.UI.ExportInfrastructure.Table table = e.ExportStructure.Tables[0]; Workbook workbook = new Workbook(); workbook.Worksheets.Add(); Worksheet worksheet = workbook.ActiveWorksheet; foreach (var row in table.Rows) { if (row.Index > 1) { worksheet.Rows[row.Index - 1].SetHeight(new RowHeight(55, true)); } foreach (var cell in row.Cells) { if (row.Index == 1 || cell.ColIndex != 2) { worksheet.Cells[cell.Index.Y - 1, cell.Index.X - 1].SetValue(cell.Value.ToString()); } else { FloatingImage image = new FloatingImage(worksheet, new CellIndex(cell.Index.Y - 1, cell.Index.X - 1), 0, 0); Stream stream = File.Open(Server.MapPath(cell.Value.ToString()), FileMode.Open); using (stream) { image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(stream, "jpg"); } worksheet.Shapes.Add(image); } } } byte[] data; using (MemoryStream ms = new MemoryStream()) { XlsxFormatProvider xlsProvider = new XlsxFormatProvider(); xlsProvider.Export(workbook, ms); data = ms.ToArray(); } Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.Headers.Remove("Content-Disposition"); Response.AppendHeader("Content-Disposition", "attachment; filename=" + RadGridLista.ExportSettings.FileName + ".xlsx"); Response.BinaryWrite(data); Response.End(); }
Would be great if font awesome could be used for the radgrid edit/delete/ icons etc....
If AllowPaging, AllowScroll and UseStaticHeaders are set to true, then there will be 2 empty <th> elements workaround: <ClientSettings> ... <ClientEvents OnGridCreated="OnGridCreated" /> </ClientSettings> <script> function OnGridCreated(sender, args) { var emptyth = $telerik.$(sender.get_element()) .find("th").filter(function (ind, item) { return item.textContent == "" }); // alert(emptyth.length) emptyth.append("<span style='display:none'>Hidden empty table header</span>") } </script>
Currently when doing a Batch Edit with the Grid each row and cell must be updated with a new/edited value before saving. Example: a User has a Grid containing records and would like to update several records because a Date field requires updating. Can it be possible for the User to select the Rows they would like to update, Edit the Date Field(using the example above), but this time when Saved all records that were selected are updated. This solution may require a modal to be displayed that shows all fields available, similar to Edit/Insert grid Popup. The appropriate field is then updated and saved only to selected records. This feature would save a lot of time by not having to edit each row individually then saving.
When Scrolling is enabled with Frozen columns in RadGrid, horizontal scrollbar not visible in Microsoft Edge. Issue appears in Microsoft Edge Version: - Microsoft Edge 42.17134.1.0 - Microsoft EdgeHTML 17.17134 WORKAROUND: Apparently, setting the horizontal scrollbar's height to 17 pixels will make Microsoft Edge display it. (Note: in case it still not displaying, you may try with 18px) To set the height, you can choose one of the options below: 1. Using CSS style to increase the size of the horizontal scrollbar by one pixel. <style type="text/css"> .RadGrid div[id$="_Frozen"] { height: 18px; /* or */ /*padding-bottom: 1px;*/ } </style> 2. Using JavaScript Subscribe the grid to its GridCreated client-side event, and in the event handler increase the element's height with the scrollbar then revert it back to its original size with a delay: <script type="text/javascript"> function GridCreated(sender, args) { $('div[id$="_Frozen"]').height(17); } </script>
With form decorator the checkboxes jump a bit to the left when cell is opened: https://www.screencast.com/t/5HwXW6kgVhb Without form decorator they get centered because of the 100% width they get https://www.screencast.com/t/oxc75Bu6lM It comes from the combination of two things: - by default, the grid cells have a left padding (as well as padding to the other sides, but that's irrelevant now) - the batch editing container does not have left padding so the editable element can better align with the text in the general case (textboxes and other editable elements usually have some left padding). With a checkbox there is no textual input, though, and so it appears to shift to the left because the left-padding of the cell is removed by the batch editing. Workaround: <style> /* note: the margins may vary in different skins, inspect the rendering if there is a */ /* for form decorator */ html .RadGrid td.rgBatchCurrent .rfdCheckboxUnchecked, html .RadGrid td.rgBatchCurrent .rfdCheckboxChecked, html .RadGrid td.rgBatchCurrent .RadCheckBoxList { margin-left: 12px; } /* if no form decorator */ html .RadGrid td.rgBatchCurrent input[type='checkbox'] { width: auto; margin-left: 16px; } /* in case you have radio buttons even though they are not a supported editable control with batch editing*/ /* for form decorator */ html .RadGrid td.rgBatchCurrent .rfdRadioUnchecked, html .RadGrid td.rgBatchCurrent .rfdRadioChecked, html .RadGrid td.rgBatchCurrent .RadRadioButtonList{ margin-left: 12px; } /* if no form decorator */ html .RadGrid td.rgBatchCurrent input[type='radio'] { width: auto; margin-left: 16px; } </style>
Hidden columns are shown on resize when the static headers and frozen column are used. Video: https://www.screencast.com/t/4Lwuvbp7 Possible workarounds: - Hide the column with Visible="False", instead of Display="False" - Hide the column on the client-side: function gridCreated(sender, args) { var masterTableView = sender.get_masterTableView(); columnIndex = masterTableView.getColumnByUniqueName("ShipName").get_element().cellIndex; setTimeout(function () { masterTableView.hideColumn(columnIndex); }, 2); } Steps to reproduse: <telerik:RadGrid RenderMode="Lightweight" HeaderStyle-Width="200px" AutoGenerateColumns="false" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" Width="100%" runat="server"> <ClientSettings> <Scrolling AllowScroll="True" UseStaticHeaders="true" FrozenColumnsCount="2"></Scrolling> </ClientSettings> <MasterTableView AutoGenerateColumns="false"> <Columns> <telerik:GridBoundColumn DataField="SongID" HeaderText="SongID" FilterControlWidth="50px" HeaderStyle-Width="50px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="SongTitle" HeaderText="Song Title" FilterControlWidth="200px"></telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CollectionName" HeaderText="Collection Name" FilterControlWidth="200px"></telerik:GridBoundColumn> <telerik:GridBoundColumn FilterControlWidth="50px" DataField="VersionID" HeaderText="VersionID" Display="false"></telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> Code Behind: protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { (sender as RadGrid).DataSource = GetData(); } private DataTable GetData() { DataTable dt = new DataTable(); dt.Columns.Add("SongID"); dt.Columns.Add("SongTitle"); dt.Columns.Add("CollectionName"); dt.Columns.Add("VersionID"); for (int i = 0; i < 20; i++) { dt.Rows.Add(i, i + 1, i + 2, i + 3); } return dt; }
When scroll inside RadGrid in Chrome on a mobile device or in the DevTools responsive/mobile mode, the browser throws [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080. I get 1 error message for every pixel the grid scrolls. The problem is due to jQuery and is reproducible with 1.12.4 and 3.3.1 versions of it.
As a temporary workaround you can use Template column with a DataField set.