Hey there,
I'm currently facing following problem:
On an ASP.NET page there is a RadGrid that gets filled on client-side using a SignalR connection.
The databinding is done like this:
var
table = $find(
'blablatableid'
);
var
tableView = table.get_masterTableView();
tableView.set_dataSource(viewModels);
tableView.dataBind();
The grid is filled and the data is displayed correctly.
During a postback caused by a button click I need to access the data in the server-side code but the grid seems to be empty. The grid doesn't have a datasource and the ItemsCollection is empty. Did I forget something or is this scenario not supported?
Best regards,
Christian
I know this has been discussed multiple times in the forum, but unfortunately I was unable to find a solution that was working for me. So here it is again. Please someone help! :)
Here is the code
<AxnGrids:AxnGrid AllowMultiRowSelection="False" AllowRowClickEventPropagation="True" AllowSorting="True" AutoGenerateColumns="False"
EnableEmbeddedSkins="False" EnableViewState="True" Height="100%" ID="TimeCardsGrid" InitialResizeToFit="True"
OnItemDataBound="TimeCardsGrid_OnItemDataBound" OnNeedDataSource="TimeCardsGrid_OnNeedDataSource" runat="server" Skin="TMW_v1"
TabIndex="-1">
<MasterTableView EditMode="EditForms" AllowMultiColumnSorting="True" TableLayout="Auto" EnableColumnsViewState="True" EnableViewState="True" >
<Columns>
<%-- columns returned: empid, emptimeid, startdate, enddate, status, empdrvid, approved --%>
<telerik:GridBoundColumn DataField="TimecardId" HeaderText="Timecard" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="100px" />
<telerik:GridBoundColumn DataField="StartDate" HeaderText="Start Date" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="100px" />
<telerik:GridBoundColumn DataField="EndDate" HeaderText="End Date" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="100px" />
<telerik:GridBoundColumn DataField="Approved" HeaderText="Approved" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="100px" />
</Columns>
<SortExpressions>
<telerik:GridSortExpression FieldName="TimecardId" SortOrder="Descending" />
</SortExpressions>
</MasterTableView>
<ClientSettings>
<ClientEvents OnGridCreating="FixGridSizers" OnRowDblClick="raiseServerCommandRowDblClick" />
<Resizing AllowColumnResize="True" ClipCellContentOnResize="False" />
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" EnableVirtualScrollPaging="False" UseStaticHeaders="True" />
</ClientSettings>
</AxnGrids:AxnGrid>
When this is run, i get the error "An item with the same key has already been added". if i comment out the line between the SortExpression, it works fine.
Any suggestions
Hi,
I've seen this use of the template which styles each tab - http://demos.telerik.com/aspnet-ajax/tabstrip/examples/functionality/server-templates/defaultcs.aspx
Is there a way to have a specific tab that contains a radbutton?
thank you
<
telerik:RadListBox
runat
=
"server"
ID
=
"listBoxSourceOS"
Height
=
"200px"
Width
=
"230px"
OnDropped
=
"listBoxSourceOS_OnDropped"
ButtonSettings-ShowTransferAll
=
"false"
EnableDragAndDrop
=
"true"
AutoPostBackOnTransfer
=
"true"
OnTransferred
=
"ListBoxSourceOS_OnTransferred"
AllowTransfer
=
"true"
TransferToID
=
"listBoxDestinationOS"
>
</
telerik:RadListBox
>
<
telerik:RadListBox
TransferToID
=
"listBoxSourceOS"
Height
=
"200px"
ID
=
"listBoxDestinationOS"
AutoPostBackOnTransfer
=
"true"
AllowTransfer
=
"true"
runat
=
"server"
Width
=
"230px"
/>
protected
void
ListBoxSourceOS_OnTransferred(
object
sender, RadListBoxTransferredEventArgs e)
{
//((Telerik.Web.UI.RadListBoxItem[])(e.Items))[0].Value
if
(e.Items !=
null
)
{
//Insert new item
//Refresh List
}
}
I know that I can localize the GridHeaders like the below
Protected Sub MyGrid_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles MyGrid.ItemCreated​
If TypeOf e.Item Is GridHeaderItem Then
Dim headerItem As GridHeaderItem = CType(e.Item, GridHeaderItem)
Dim header As GridHeaderItem = CType(e.Item, GridHeaderItem)
header.Cells(9).Text = Resources.PageLocalizations.GridHeaderApp
header("Active").Text = Resources.PageLocalizations.GridHeaderActive​
End If
End Sub
But the headers in Insert/edit mode doesn't get changed when using EditMode="PopUp"
Anyone knows how to edit the headers there?
Best Regards Pelle
I'd much rather comment out a Telerik line in HTML than remove it. Using <!-- --> yields an error. Is this this possible?
<
telerik:RadGrid
ID
=
"Dashboard_RadGrid"
AutoGenerateColumns
=
"false"
AllowPaging
=
"true"
OnNeedDataSource
=
"Dashboard_NeedDataSource"
OnItemDataBound
=
"Dashboard_ItemDataBound"
OnItemCommand
=
"Dashboard_ItemCommand"
PageSize
=
"20"
EnableViewState
=
"true"
SelectedItemStyle-CssClass
=
"MeasuredResultsDetail"
runat
=
"server"
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
EnablePostBackOnRowClick
=
"true"
>
<
MasterTableView
DataKeyNames
=
"Build.ID, BuildResult.ID"
Name
=
"TableMain"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Build.BuildNumber"
HeaderText
=
"Build Number"
HeaderStyle-Width
=
"120px"
/>
<
telerik:GridBoundColumn
DataField
=
"BuildResult.CreationDate"
HeaderText
=
"Date"
HeaderStyle-Width
=
"140px"
DataFormatString="<nobr>{0}</
nobr
>" />
<!--
<telerik:GridBoundColumn DataField="BuildResult.EvaluatorResultsErrorLevel" HeaderText="Full" HeaderStyle-Width="80px" />
-->
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
hey
im using advanced databinding with data from sql db.
so i have this code that when a column (files recieved) is sorted, i highlight rows that a month has passed since the since it was created, files were received but still it was not processed (to alert users). I had the idea i will add an unbound column, and assign it a priority number for the rows that are highlighted. There will be different priority for different "rules", so i could have some rows highlighted red with priority 1, while some are yellow with priority 2. now when this happens i want to create a default sort, before any other sorts are applied, that the rows with highest priority will show up first.
so thats the jist of what im trying to do. i know the regular sort wont work because the item is not bound, so its not a dataitem. what i tried to do was on the onneeddatasource event, after i have my datatable, i apply the sort by priority on the dataview of the datatable (the datatable does have the column with priority with the proper values). This seems to work as the datatable i assign as the datasource for the grid does show up in the exact order it should, priority items first. But i see that the other sort expressions of other columns are not yet applied, this leads me to believe that the datasource gets sorted after the event, overwriting the manual sort i applied.
is there an event i should override where i can plug in my manual sort? or maybe someone has a better idea how to implement the functionality im looking to achieve? here is the relevant code:
protected
void
rgListingsReport_NeedDataSource(
object
source, GridNeedDataSourceEventArgs e)
{
if
((HttpContext.Current.Cache[
"data"
] ==
null
)
{
// gets datatable from sql
}​
else
{
_dtReportsSource = (DataTable)HttpContext.Current.Cache[
"data"
];
}
if
(_dtReportsSource !=
null
)
{
if
(doSort) //true when there are rows with priority
{
_dtReportsSource.DefaultView.Sort =
"NoticePriority DESC"
;
_dtReportsSource = _dtReportsSource.DefaultView.ToTable();
rgListingsReport.DataSource = _dtReportsSource;
}
else
{
rgListingsReport.DataSource = _dtReportsSource;
}
}
}
​
on the item databound event i set the priority values for the rows and datatable stored in cache
if
(rowColor == Color.Red)
{
dataBoundItem[
"NoticePriority"
].Text =
"1"
;
(HttpContext.Current.Cache[
"data"
]
as
DataTable).Rows[e.Item.RowIndex][
"NoticePriority"
] =
"1"
;
}
else
{
dataBoundItem[
"rowindex"
].Text =
"0"
;
dataBoundItem[
"NoticePriority"
].Text =
"0"
;
}