var
codeMasterSource = new Array();
function
DataBind() {
grd = $find(
'Grid').get_masterTableView();
grd.set_dataSource(codeMasterSource);
grd.dataBind();
}
Hello Telerik Team,
I have a requirement where i need to bind the scheduler to a sql database table and display some columns
from the table on top of the cell.I mean by default scheduler just shows up the subject on the cell but i wanted to display some additional columns from database example priority column, Description column,etc on top of each cell instead of the edit template.At the same time i need to colour code the cell based on the status column values.
I have connected the scheduler to sql datasource already and able to fetch the information.
Any pointers in this direction are greatly appreciated.
Thank you
Smith
| <telerik:RadGrid ID="grdCheckData" runat="server" AllowPaging="True" AllowSorting ="true" GridLines="both" OnPageIndexChanged="grdCheckData_PageIndexChanged" OnPageSizeChanged="grdCheckData_PageSizeChanged" |
| OnSortCommand="grdCheckData_SortCommand" ShowGroupPanel="true" ><%--OnExcelExportCellFormatting="grdCheckData_ExcelExportCellFormatting" OnExcelMLExportRowCreated="grdCheckData_ExcelMLExportRowCreated" OnExcelMLExportStylesCreated="grdCheckData_ExcelMLExportStylesCreated" --%> |
| <ClientSettings AllowColumnsReorder ="true" AllowDragToGroup="true" ReorderColumnsOnClient="true" Scrolling-AllowScroll="true" > |
| <Resizing AllowRowResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True" |
| AllowColumnResize="True"></Resizing> |
| </ClientSettings> |
| <GroupingSettings ShowUnGroupButton="true" UnGroupTooltip ="Drag the field to group by." /> |
| <SortingSettings SortedBackColor="Azure" EnableSkinSortStyles="false" /> |
| <ExportSettings FileName ="CheckInfo" OpenInNewWindow="true" IgnorePaging ="true" ExportOnlyData="true" > |
| <Excel Format="excelML" /> |
| <Pdf AllowPrinting="true" /> |
| </ExportSettings> |
| <MasterTableView AutoGenerateColumns ="false" > |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn > |
| <Columns > |
| <telerik:GridBoundColumn DataField ="BANK" UniqueName ="BANK" SortExpression="BANK" ReadOnly ="true" HeaderText ="Bank" > <ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="BANKNO" UniqueName ="BANKNO" SortExpression ="BANKNO" ReadOnly ="true" HeaderText ="Bank ID" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="PMSID" UniqueName ="PMSID" SortExpression ="PMSID" ReadOnly ="true" HeaderText ="PMS ID" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="SSN" UniqueName ="SSN" ReadOnly ="true" SortExpression ="SSN" HeaderText ="SSN" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="FNAME" UniqueName ="FNAME" ReadOnly ="true" SortExpression ="FNAME" HeaderText ="First Name" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="LNAME" UniqueName ="LNAME" ReadOnly ="true" SortExpression ="LNAME" HeaderText ="Last Name" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="LET" UniqueName ="LET" ReadOnly ="true" HeaderText ="Let" SortExpression ="LET" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="CHECKNUM" UniqueName ="CHECKNUM" ReadOnly ="true" SortExpression ="CHECKNUM" HeaderText ="Check No." ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="CHECKDT" UniqueName ="CHECKDT" ReadOnly ="true" SortExpression ="CHECKDT" HeaderText ="Check Date" DataType = "System.DateTime" DataFormatString="{0:MM/dd/yyyy}" HtmlEncode="false" ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="NETPAY" UniqueName ="NETPAY" DataFormatString="{0:$###,###.##}" ReadOnly ="true" SortExpression ="NETPAY" HeaderText ="Net Amt." ><ItemStyle Width ="100" /></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField ="DISPDT" UniqueName ="DISPDT" ReadOnly ="true" SortExpression ="DISPDT" HeaderText ="Disp. Date" DataType = "System.DateTime" DataFormatString="{0:MM/dd/yyyy}" HtmlEncode="false" > |
| <ItemStyle Width ="100" /> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
Here is my code for export.
| protected void btnExportExl_Click(object sender, EventArgs e) |
| { |
| try |
| { |
| if ((!IsPostBack) || (!IsValid)) |
| return; |
| RadGrid grdCheckData = (RadGrid)dataPanel.FindItemByValue("CheckData").FindControl("grdCheckData"); |
| grdCheckData.MasterTableView.ExportToExcel(); |
| } |
| catch (Exception ex) |
| { |
| throw; |
| } |
| } |
| protected void grdCheckData_ExcelExportCellFormatting(object source, ExcelExportCellFormattingEventArgs e) |
| { |
| } |
| protected void grdCheckData_ExcelMLExportStylesCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e) |
| { |
| foreach (Telerik.Web.UI.GridExcelBuilder.StyleElement style in e.Styles) |
| { |
| if (style.Id == "headerStyle") |
| { |
| style.FontStyle.Bold = true; |
| style.FontStyle.Color = System.Drawing.Color.Brown; |
| style.InteriorStyle.Color = System.Drawing.Color.Wheat; |
| style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid; |
| } |
| else if (style.Id == "itemStyle") |
| { |
| style.NumberFormat.FormatType = Telerik.Web.UI.GridExcelBuilder.NumberFormatType.Currency; |
| style.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.HorizontalAlignmentType.Left; |
| style.InteriorStyle.Color = System.Drawing.Color.WhiteSmoke; |
| style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid; |
| } |
| else if (style.Id == "alternatingItemStyle") |
| { |
| style.NumberFormat.FormatType = Telerik.Web.UI.GridExcelBuilder.NumberFormatType.Currency; |
| style.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.HorizontalAlignmentType.Left; |
| style.InteriorStyle.Color = System.Drawing.Color.LightGray; |
| style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid; |
| } |
| } |
| } |
| protected void grdCheckData_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e) |
| { |
| if (e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.HeaderRow) |
| { |
| Telerik.Web.UI.GridExcelBuilder.RowElement row = new Telerik.Web.UI.GridExcelBuilder.RowElement(); |
| Telerik.Web.UI.GridExcelBuilder.CellElement cell = new Telerik.Web.UI.GridExcelBuilder.CellElement(); |
| cell.Data.DataItem = "NYC Department Of Education"; |
| row.Cells.Add(cell); |
| e.Worksheet.Table.Rows.Insert(0, row); |
| } |
| } |
| Object reference not set to an instance of an object. |
| Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. |
| Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. |
| Source Error: |
| An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
| Stack Trace: |
| [NullReferenceException: Object reference not set to an instance of an object.] |
| Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderForm(HtmlTextWriter nullWriter, Control form) +864 |
| System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256 |
| System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 |
| System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +8676409 |
| System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32 |
| System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51 |
| System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 |
| System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 |
| System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40 |
| Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderPage(HtmlTextWriter nullWriter, Control page) +93 |
| System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256 |
| System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 |
| System.Web.UI.Page.Render(HtmlTextWriter writer) +29 |
| System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 |
| System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 |
| System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 |
| System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266 |
| -------------------------------------------------------------------------------- |
| Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082 |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| <script type="text/javascript"> |
| function ChangeDisplay(elm) { |
| var div = document.getElementById("Wrapper2"); |
| if (elm.value == "0") { |
| div.style.cssText = "display: none;"; |
| } |
| else { |
| div.style.cssText = "display: block;"; |
| } |
| } |
| </script> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <asp:ScriptManager ID="SM" runat="server"></asp:ScriptManager> |
| <asp:ListBox ID="LB1" runat="server" onchange="ChangeDisplay(this);" Rows="1" SelectionMode="Single"> |
| <asp:ListItem Text="Hide" Value="0"></asp:ListItem> |
| <asp:ListItem Text="Show" Value="1"></asp:ListItem> |
| </asp:ListBox> |
| <div id="Wrapper"> |
| <div style="float: left; padding-top: 2px;"> |
| <telerik:RadEditor ID="RadEditor1" runat="server" Skin="Default" Height="200" Width="610" ContentFilters="RemoveScripts" EnableResize="false" EditModes="Design"> |
| </telerik:RadEditor> |
| </div> |
| </div> |
| <div id="Wrapper2" style="display: none;"> |
| <div style="float: left; padding-top: 2px;"> |
| <telerik:RadEditor ID="RadEditor2" runat="server" Skin="Default" Height="200" Width="610" ContentFilters="RemoveScripts" EnableResize="false" EditModes="Design"> |
| </telerik:RadEditor> |
| </div> |
| </div> |
| </form> |
| </body> |
| </html> |
Hello ,
I'm using radticker in my form in that I need to take data from xml file but I'm getting error, FOA I'm using following XML code
<test> <test Heading="Heading One" Body="This is Body"/> <test Heading="Heasing two" Body="This is body two."/> </test>
below is what I'm using in aspx code
<telerik:RadRotator ID="RadRotator1" runat="server" ScrollDirection="Left" ScrollDuration="7000" DataSourceID="XmlDataSource1" RenderingCompatibility="3.5" Skin="Windows7">
<ItemTemplate>
<telerik:RadTicker ID="RadTicker1" runat="server" AutoStart="true" LineDuration="4000" Loop="true">
<Items>
<telerik:RadTickerItem Text='<%# XPath("Heading") %>'>
</telerik:RadTickerItem>
<telerik:RadTickerItem Text='<%# XPath("Body") %>'>
</telerik:RadTickerItem>
</Items>
</telerik:RadTicker>
</ItemTemplate>
</telerik:RadRotator>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml">
</asp:XmlDataSource>
After running this I don't get any output in browser, but if I put simple text instead of xpath.... it appears in browser tickering & rotating but not if I choose from xml file
In above code what I need to do is that firstly heading1 and body1 should ticker in first rotation and heading2 and body2 should ticker in second rotation
If anyone could provide solution for this that would be great for me I tried for this a lot but with no success till now
Plz reply
Thanks
