Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
69 views

Hello,

 I have Q1 2015 and I added the RadMap to another project and used it. Now when I created another project I cannot find it to add to the toolbox. I added the Telerik.Web.UI.DLL and then went to choose items for the toolbox and RadMap is no where to be found. How can I get it added so I can use it?

Thanks,

Warren

 

Ianko
Telerik team
 answered on 29 Sep 2015
1 answer
39 views

I am using  external css for editor , but it doesn't work with Mozila , and working fine with Chrome

So, please provide me the solution  for this strange issue

 

 

 

Ianko
Telerik team
 answered on 29 Sep 2015
1 answer
46 views

Hi,

I want to change skin file in my website without affect web.config file. now i declare  <appSettings><add key="Telerik.Skin" value="WebBlue" /></appSettings>. In this case i am not able to change skin without affecting web,config file. if any changes done in web.config file the website should logout. i want this feature?

Please help anyone ASAP,

 

Thanks,

Marin Bratanov
Telerik team
 answered on 29 Sep 2015
4 answers
302 views

Running 2015.2.826.45

This used to work, but we recently changed environments and I am not sure where to check for problems.

<telerik:RadAsyncUpload runat="server" Width="300" SkinID="defaultUpload" ID="uImportFile" OnFileUploaded="fileUploaded" AllowedFileExtensions=".xls,.xlsx"  OverwriteExistingFiles="True" AutoAddFileInputs="False" MaxFileInputsCount="1"                    TargetFolder="~/UploadedFiles" OnClientFileUploadFailed="uploadFailed">
</telerik:RadAsyncUpload>

As soon as the user selects the file to be uploaded, a temp file is created based on the name of the upload in App_Data/RadUploadTemp.  But then a postback happens, the file is removed from RadUPloadTemp, but it not moved into the UploadedFiles folder. ​This happens on a production server as well as locally.  I have set permissions on the folder to full control.  Tried Chrome, IE, FireFox and got the same results.  The OnClientUploadFailed event is not firing.  The OnFileUploaded even is firing.  What am I missing?

Thanks,

Randy

Ivan Danchev
Telerik team
 answered on 28 Sep 2015
11 answers
400 views

I've followed the instructions on extending the RadAsyncUploadHandler here, and I've encountered a very similar problem to this thread.

If you implement a custom
AsyncUploadHandler and upload a file it works the first time, but each subsequent time you upload a file it fails with no explanation as why it failed. It works again after IISRESET or process reset. It seems this may have something to do with first upload session not being properly terminated, session or something along those lines. 

It appears that this problematic behavior is also 
occurring on the latest Telerik assemblies too. I've included a simple project that reproduces the said behavior. Could you please let me know how to fix this? I need to use this feature of the RadAsycUpload so I can provide data about the parsed upload file back to the client without full page postback. Please let me know how I can get this working.

Thanks,
-James

[Files]
Project Files
Upload Test File

saravanan
Top achievements
Rank 1
 answered on 28 Sep 2015
5 answers
455 views

I'm fairly new to Telerik so please bear with me.

 

I have two buttons: One does a SQL Insert and the other does a SQL Update, both work correctly as they currently are.  The update button is currently hidden from the user.  What I want to happen is if the user clicks the EditCommand link in the RadGrid, I want the Insert button to hide and the Update button to become visible. My question is - how do you interact with the EditCommand in C#?

Konstantin Dikov
Telerik team
 answered on 28 Sep 2015
1 answer
140 views

Hi Team,

 Please find the below code, the drag and drop event is not firing in the radgrid.

Please give provide me the solutions.

Thanks,

Rajesh

 

<telerik:RadGrid ID="Parts" ClientIDMode="Static" runat="server" AllowPaging="True" AllowSorting="True" ClientSettings-AllowAutoScrollOnDragDrop="true"
AutoGenerateColumns="False" GridLines="None" ShowStatusBar="True" CssClass="Parts" ClientSettings-AllowDragToGroup="true" ClientSettings-AllowRowsDragDrop="true">
<ClientSettings AllowRowsDragDrop="true">
<Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />
</ClientSettings>
<MasterTableView Name="PartsTableView" DataKeyNames="InventoryID" AllowSorting="True" NoDetailRecordsText="No Items" HierarchyLoadMode="ServerBind"
NoMasterRecordsText="No Items Added" CommandItemDisplay="Bottom" EditMode="Batch">
<CommandItemSettings ShowAddNewRecordButton="false" />
<BatchEditingSettings EditType="Cell" />
<DetailTables>
<telerik:GridTableView Name="ComponentDetails" Caption="Component Details" DataKeyNames="InventoryID"
runat="server">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="ParentID" MasterKeyField="InventoryID" />
</ParentTableRelation>
<Columns>
<telerik:GridBoundColumn DataField="ParentID" Display="false" UniqueName="ParentID" />
<telerik:GridBoundColumn DataField="InventoryID" HeaderText="InventoryID" ReadOnly="true"
UniqueName="InventoryID" />
<telerik:GridBoundColumn DataField="FormNumber" HeaderText="Form #" UniqueName="FormNumber" />
<telerik:GridBoundColumn DataField="Description" HeaderText="Description" ReadOnly="true"
UniqueName="Description" Display="True" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridTemplateColumn UniqueName="ThumbNail">
<ItemTemplate>
<asp:Image ID="imgThumbNail" runat="server" ImageUrl='<%#Eval("ImageUrl")%>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="InventoryID" UniqueName="FormNumber" Display="false" />
<telerik:GridBoundColumn DataField="Text" HeaderText="Product Code" />
<telerik:GridBoundColumn DataField="Description" Display="false" />
<telerik:GridTemplateColumn UniqueName="Description" HeaderText="Title">
<ItemTemplate>
<asp:Label ID="lblDescription" runat="server" Text='<%#Eval("Description") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDescription" runat="server" Text='<%#Eval("Description") %>'>
</asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="Type" Display="false" />
<telerik:GridEditCommandColumn ButtonType="ImageButton" EditText="Edit" UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn ButtonType="ImageButton"
CommandName="DeleteInventory" Text="Remove" UniqueName="Delete">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton"></ItemStyle>
<HeaderStyle Width="20px"></HeaderStyle>
</telerik:GridButtonColumn>
<telerik:GridDragDropColumn HeaderStyle-Width="18px" Visible="false">
</telerik:GridDragDropColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowRowsDragDrop="True" AllowColumnsReorder="true" ReorderColumnsOnClient="true">
<Selecting AllowRowSelect="True" EnableDragToSelectRows="false"></Selecting>
<ClientEvents OnRowDropping="demo.onRowDropping"></ClientEvents>
<Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
</ClientSettings>
</telerik:RadGrid>
<asp:XmlDataSource ID="XMLBookBuilderSource" runat="server" EnableCaching="false">
</asp:XmlDataSource>
<telerik:GridTextBoxColumnEditor ID="GridTextBoxEditor" runat="server" TextBoxStyle-Width="230px"></telerik:GridTextBoxColumnEditor>

 

DragDrop.js:

 

(function ($, undefined) {
var grdPendingOrders;
var grdShippedOrders;

var demo = window.demo = {};

demo.onGridCreated = function (sender, args) {
grdPendingOrders = $telerik.findControl(document, "Parts");
grdShippedOrders = sender;
}
demo.onRowDropping = function (sender, args) {
if (sender.get_id() == Parts.get_id()) {
var node = args.get_destinationHtmlElement();
if (!isChildOf(grdShippedOrders.get_id(), node) && !isChildOf(Parts.get_id(), node)) {
args.set_cancel(true);
}
}
else {
var node = args.get_destinationHtmlElement();
if (!isChildOf('trashCan', node)) {
args.set_cancel(true);
}
else {
if (confirm("Are you sure you want to delete this order?"))
args.set_destinationHtmlElement($get('trashCan'));
else
args.set_cancel(true);
}
}
};


function isChildOf(parentId, element) {
while (element) {
if (element.id && element.id.indexOf(parentId) > -1) {
return true;
}
element = element.parentNode;
}
return false;
};
})($telerik.$);

 

code behind:

-----------------

 

Protected Sub Parts_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles Parts.ItemCommand
If e.CommandName = "DeleteInventory" Then
Dim filename As String = _uploadSystemPath & "tree.xml"
Dim XMLDoc As XDocument = XDocument.Load(_uploadSystemPath & "tree.xml")
XMLDoc.Root.Elements("Node")(e.Item.ItemIndex).Remove()
XMLDoc.Save(filename)
'Parts.DataSource = Nothing
Parts.Rebind()
End If
End Sub
Protected Sub Parts_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles Parts.NeedDataSource
If File.Exists(_uploadSystemPath & "tree.xml") Then
XMLBookBuilderSource.DataFile = _uploadSystemPath & "tree.xml"
Parts.DataSource = Nothing
Parts.DataSource = XMLBookBuilderSource
End If
End Sub
Protected Sub Parts_UpdateCommand(sender As Object, e As GridCommandEventArgs) Handles Parts.UpdateCommand
If e.CommandName = "Update" Then
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim strTitle As String = DirectCast(editedItem.FindControl("txtDescription"), TextBox).Text
Dim XMLDoc As XDocument = XDocument.Load(_uploadSystemPath & "tree.xml")
XMLDoc.Root.Elements("Node")(e.Item.ItemIndex).SetAttributeValue("Description", strTitle)
XMLDoc.Save(filename)
Parts.Rebind()
End If
End Sub
Protected Sub Parts_RowDrop(sender As Object, e As GridDragDropEventArgs) Handles Parts.RowDrop
Dim i As Integer = e.DropPosition
End Sub

Viktor Tachev
Telerik team
 answered on 28 Sep 2015
3 answers
69 views

Hi,

 

In our CMS I always used

 

RadFileExplorer1.Upload.Width = 440

This now breaks the FileExplorer in newest dll 4.5

Amending it to RadFileExplorer1.Upload.Width = Unit.Pixel(440)

 

to no avail...

 

Marc

Vessy
Telerik team
 answered on 28 Sep 2015
3 answers
297 views

When the grid loads, the rows in the MasterTableView aren't expanded, so no scrollbar appears. When the user expands the rows, the vertical scrollbar appears as expected. But, after a postback, the rows are still expanded and the scrollbar is gone. I've tried setting a scrollheight. I've tried having one column without a set width.

 Here is my grid:

<telerik:RadGrid ID="rgUnits"
                         runat="server"
                         AllowSorting="True"
                         AutoGenerateColumns="False"
                         AllowAutomaticUpdates="True"
                         AllowMultiRowSelection="True"
                         Height="380px"
                         Width="100%"
                         OnPreRender="rgUnits_OnPreRender"
                         OnItemCreated="rgUnits_ItemCreated"
                         OnNeedDataSource="rgUnits_NeedDataSource"
                         OnDetailTableDataBind="rgUnits_DetailTableDataBind">
            <MasterTableView ShowHeadersWhenNoRecords="false"
                             EnableNoRecordsTemplate="true"
                             DataKeyNames="UnitId"
                             ClientDataKeyNames="UnitId"
                             AutoGenerateColumns="false"
                             TableLayout="Fixed"
                             ItemStyle-VerticalAlign="Top"
                             AlternatingItemStyle-VerticalAlign="Top"
                             HeaderStyle-HorizontalAlign="Center"
                             AlternatingItemStyle-HorizontalAlign="Center"
                             HierarchyDefaultExpanded="False"
                             HierarchyLoadMode="Client">
                <NoRecordsTemplate>
                    <div class="text-warning text-center">
                        <p class="bg-warning padme10 ">There are no acreage lines associated with the selected item.</p>
                    </div>
                </NoRecordsTemplate>
                <DetailTables>
                    <telerik:GridTableView ShowHeadersWhenNoRecords="True"
                                           EnableNoRecordsTemplate="True"
                                           DataKeyNames="ReportingId"
                                           ClientDataKeyNames="ReportingId"
                                           AutoGenerateColumns="false"
                                           ItemStyle-VerticalAlign="Top"
                                           AlternatingItemStyle-VerticalAlign="Top"
                                           HeaderStyle-HorizontalAlign="Center"
                                           HierarchyLoadMode="ServerBind"
                                           Width="100%"
                                           CommandItemDisplay="bottom">
                        <CommandItemTemplate>
                            <div class="padme5">
                            <asp:Button ID="btnAssignRemove" OnClick="btnAssignRemove_OnClick" CssClass="btn btn-default btn-link btn-sm" Text="Assign/Remove" runat="server"></asp:Button>
                            <asp:Button ID="btnFeatureDefaultPlantDate" OnClick="btnFeatureDefaultPlantDate_OnClick" CssClass="pull-right btn btn-default btn-link btn-sm" Text="Default Plant Date" runat="server"></asp:Button>
                            <asp:Button ID="btnFeaturePlantedAcres" OnClick="btnFeaturePlantedAcres_OnClick" CssClass="pull-right btn btn-default btn-link btn-sm margrt5" Text="Plant 100% of Acres" runat="server"></asp:Button>
                            </div>
                        </CommandItemTemplate>
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="UnitId"
                                                        MasterKeyField="UnitId"/>
                        </ParentTableRelation>
                        <Columns>
                            <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" ItemStyle-HorizontalAlign="Center"/>
                            <telerik:GridCalculatedColumn HeaderText="Farm/Tract/Field"
                                                          UniqueName="FarmTractField"
                                                          DataFields="FarmNum,TractNum,FieldNum"
                                                          ItemStyle-HorizontalAlign="Center"
                                                          Expression='{0} + "/" + {1} + "/" + {2}'/>
                            <telerik:GridBoundColumn DataField="DisplayAcres"
                                                     DataFormatString="{0:F2}"
                                                     HeaderText="CLU Acres"
                                                     UniqueName="DisplayAcres"
                                                     ItemStyle-HorizontalAlign="Right"/>
                            <telerik:GridTemplateColumn UniqueName="PlantedAcres"
                                                        HeaderText="Planted Acres"
                                                        ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <telerik:RadNumericTextBox ID="txtPlantedAcres"
                                                               UniqueName="txtPlantedAcres"
                                                               CssClass="form-control inline-form input-xs"
                                                               DbValue='<%#Bind("PlantedAcres") %>'
                                                               OnTextChanged="txtPlantedAcres_OnTextChanged"
                                                               AutoPostBack="True"
                                                               Type="number"
                                                               Width="67px"
                                                               runat="server" MinValue="0" MaxValue='<%# Convert.ToDouble(Eval("DisplayAcres")) %>'>
                                    </telerik:RadNumericTextBox>
                                    </div>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn UniqueName="PlantDate"
                                                        DataField="PlantDate"
                                                        HeaderText="Plant Date"
                                                        ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <telerik:RadDatePicker ID="rdpFeaturePlantDate" runat="server"
                                                           DbSelectedDate='<%#Bind("PlantDate") %>'
                                                           OnSelectedDateChanged="rdpFeaturePlantDate_OnSelectedDateChanged"
                                                           AutoPostBack="True"
                                                           Calendar-ShowRowHeaders="False"
                                                           CssClass="inline-form input-date"/>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="Fid"
                                             UniqueName="Fid"
                                             Display="False"/>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <telerik:GridBoundColumn DataField="FormattedUnitNumber"
                                             HeaderText="Unit Number"
                                             UniqueName="FormattedUnitNumber"
                                             ItemStyle-Width="120px"
                                             HeaderStyle-Width="120px"
                                             ItemStyle-HorizontalAlign="Left"/>
                    <telerik:GridBoundColumn DataField="CropName"
                                             HeaderText="Crop"
                                             UniqueName="Crop"
                                             ItemStyle-Width="63px"
                                             HeaderStyle-Width="63px"
                                             ItemStyle-HorizontalAlign="Center"/>
                    <telerik:GridBoundColumn DataField="CommodityTypeName"
                                             HeaderText="Type"
                                             UniqueName="Type"
                                             ItemStyle-Width="132px"
                                             HeaderStyle-Width="132px"
                                             ItemStyle-HorizontalAlign="Center"/>
                    <telerik:GridBoundColumn DataField="PracticeName"
                                             HeaderText="Practice"
                                             UniqueName="Practice"
                                             ItemStyle-Width="69px"
                                             HeaderStyle-Width="69px"
                                             ItemStyle-HorizontalAlign="Center"/>
             
                    <telerik:GridTemplateColumn UniqueName="Shareholders"
                                                HeaderText="Share- Holders"
                                                HeaderStyle-Width="60px"
                                                ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                    <telerik:RadScriptBlock ID="rsbScript" runat="server">
                                <script type="text/javascript">
                                    $(document).ready(function () {
                                        $(function () {
                                            $('[data-toggle="popover"]').popover()
                                        })
                                    });
                                </script>
                            </telerik:RadScriptBlock>
                            <a href="javascript:void(0);"  data-toggle="popover" data-placement="left" data-trigger="hover" title="Shareholders"
                                data-html="true"  data-content='<%# Eval("OtherShareholder") %>'>View</a>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="SharePercent"
                                                HeaderText="Share %"
                                                HeaderStyle-Width="71px"
                                                ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <div class="form-inline">
                                <telerik:RadNumericTextBox ID="txtSharePercent"
                                                           DbValue='<%#Bind("SharePercent") %>'
                                                           OnTextChanged="txtSharePercent_OnTextChanged"
                                                           AutoPostBack="True"
                                                           CssClass="form-control inline-form"
                                                           Type="number"
                                                           width="60px"
                                                           runat="server" MaxValue="100" MinValue="1">
                                </telerik:RadNumericTextBox>
                            </div>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="PPLP"
                                                HeaderText="PP/LP"
                                                HeaderStyle-Width="78px"
                                                ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:DropDownList runat="server" ID="ddlAcreageType"
                                              CssClass="form-control inline-form input-xs"
                                              SelectedValue='<%# Bind("AcreageType") %>'
                                              OnSelectedIndexChanged="ddlAcreageType_OnSelectedIndexChanged"
                                              AutoPostBack="True">
                                <asp:ListItem Value="None" Text="None"></asp:ListItem>
                                <asp:ListItem Value="PreventedPlanting" Text="PP"></asp:ListItem>
                                <asp:ListItem Value="LatePlanting" Text="LP"></asp:ListItem>
                            </asp:DropDownList>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="PlantedAcres"
                                                HeaderText="Planted Acres"
                                                HeaderStyle-Width="90px"
                                                ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <div class="form-inline">
                                <telerik:RadNumericTextBox ID="txtPlantedAcres" ReadOnly="True" CssClass="form-control inline-form input-xs" Type="number" Width="67px" runat="server">
                                </telerik:RadNumericTextBox>
                            </div>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="PlantDate"
                                                HeaderText="Plant Date"
                                                DataField="PlantDate"
                                                HeaderStyle-Width="114px"
                                                ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <telerik:RadDatePicker ID="rdpUnitPlantDate"
                                                   DbSelectedDate='<%#Bind("PlantDate") %>'
                                                   OnSelectedDateChanged="rdpUnitPlantDate_OnSelectedDateChanged"
                                                   AutoPostBack="True"
                                                   runat="server"
                                                   Calendar-ShowRowHeaders="False"
                                                   CssClass="inline-form input-date"/>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="Actions"
                                                HeaderText="Actions"
                                                HeaderStyle-Width="55px"
                                                ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <div class="dropdown">
                                <a href="#" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                    <i class="fa fa-cog fa-lg"></i>
                                </a>
                                <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu1">
                                    <li>
                                        <asp:LinkButton ID="lnkDeleteCopy" runat="server" OnClientClick='<%# "lnkDeleteCopy_ClientClicked("+ Eval("UnitId") + ");" %>'>Delete Copy</asp:LinkButton>
                                    </li>
                                    <li>
                                        <asp:LinkButton ID="lnkCopyUnit" runat="server" OnClientClick='<%# "lnkCopyUnit_ClientClicked("+ Eval("UnitId") + "); return false;" %>'>Copy Unit</asp:LinkButton>
                                    </li>
                                    <li>
                                        <asp:LinkButton ID="lnkPlantedAcres100" runat="server" OnClick="lnkPlantedAcres100_OnClick">Planted Acres 100%</asp:LinkButton>
                                    </li>
                                    <li>
                                        <asp:LinkButton ID="lnkDefaultPlantDate" runat="server" OnClick="lnkDefaultPlantDate_OnClick">Default Plant Date</asp:LinkButton>
                                    </li>
                                </ul>
                            </div>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="IsCopy"
                                             UniqueName="IsCopy"
                                             Display="False"/>
                </Columns>
            </MasterTableView>
            <ClientSettings EnableRowHoverStyle="true"
                            ClientEvents-OnRowSelected="rgUnits_OnRowSelected"
                            AllowExpandCollapse="True">
                <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" ScrollHeight="350px"></Scrolling>
                <Selecting AllowRowSelect="True"></Selecting>
            </ClientSettings>
        </telerik:RadGrid>

Konstantin Dikov
Telerik team
 answered on 28 Sep 2015
2 answers
389 views

Hello,

I'm trying to export the contents of a RadGrid that has a child RadGrid in its NestedViewTemplate to Excel format.  I've found some examples on how to export the contents of a RadGrid to Excel, however, those examples only seem to export the parent radgrid's contents and not the child content.  Is there a way to do this?  An example would be very much appreciated.  Thanks.

Here's my code for the RadGrid:

<telerik:RadButton ID="btnExportToExcel" runat="server" Text="Export to Excel" OnClick="btnExportToExcel_Click"></telerik:RadButton>
 
<telerik:RadGrid ID="grdViewInventory" runat="server"
    AutoGenerateColumns="False"
    AllowPaging="false"
    AllowSorting="false"
    OnColumnCreated="grdViewInventory_ColumnCreated"
    OnNeedDataSource="grdViewInventory_NeedDataSource"
    Skin="Metro"
    ShowHeader="false"
    ShowFooter="false"
    CssClass="IV_MasterGrid" CellPadding="0" CellSpacing="0">
    <MasterTableView HierarchyDefaultExpanded="true" HierarchyLoadMode="ServerOnDemand" EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true" DataKeyNames="DataKey" RetainExpandStateOnRebind="true">
        <NoRecordsTemplate>
            <div class="div_NoRecordsTemplate">No Components Found.</div>
        </NoRecordsTemplate>
        <NestedViewSettings>
            <ParentTableRelation>
                <telerik:GridRelationFields DetailKeyField="DataKey" MasterKeyField="DataKey" />
            </ParentTableRelation>
        </NestedViewSettings>
        <NestedViewTemplate>
            <telerik:RadGrid ID="rgNestedViewInventory" runat="server" AutoGenerateColumns="false" Width="99.5%" CssClass="IV_NestedGrid" OnNeedDataSource="rgNestedViewInventory_NeedDataSource">
                <MasterTableView EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true" TableLayout="Fixed">
                    <Columns>
                        <telerik:GridBoundColumn DataField="FilterType" HeaderText="Filter Type" ReadOnly="True" UniqueName="FilterType">
                            <HeaderStyle CssClass="IV_FT_Nested" Wrap="false" />
                            <ItemStyle CssClass="IV_FT_Nested" Wrap="false" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ModelNumber" HeaderText="Model Number" ReadOnly="True" UniqueName="ModelNumber">
                            <HeaderStyle CssClass="IV_MN_Nested" Wrap="false" />
                            <ItemStyle CssClass="IV_MN_Nested" Wrap="false" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="PartNumber" HeaderText="Part Number" ReadOnly="True" UniqueName="PartNumber">
                            <HeaderStyle CssClass="IV_PN_Nested" Wrap="false" />
                            <ItemStyle CssClass="IV_PN_Nested" Wrap="false" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="FilterDimension" HeaderText="Filter Size" ReadOnly="True" UniqueName="FilterDimension">
                            <HeaderStyle CssClass="IV_FDE_Nested" Wrap="false" />
                            <ItemStyle CssClass="IV_FDE_Nested" Wrap="false" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Quantity" HeaderText="Quantity" ReadOnly="True" UniqueName="FilterManufacturer">
                            <HeaderStyle CssClass="IV_QTY_Nested" Wrap="false" />
                            <ItemStyle CssClass="IV_QTY_Nested" Wrap="false" />
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </NestedViewTemplate>
        <Columns>
            <telerik:GridTemplateColumn UniqueName="GroupHeaderColumn" Resizable="false" SortExpression="PropertyNumber">
                <ItemTemplate>
                    <asp:Label runat="server" ID="Label1" Text='<%# Eval("Building") %>' />
                    <asp:Label runat="server" ID="Label2" Text='<%# " - (" + Eval("PropertyNumber") + ") - " %>' />
                    <asp:Label runat="server" ID="Label4" Text='<%# Eval("UnitTag") %>' />
                    <asp:Label runat="server" ID="Label3" Text='<%# " - " + Eval("AHUType") %>' />
                    <asp:Label runat="server" ID="Label5" Text='<%# " - " + Eval("Configuration") %>' />
                </ItemTemplate>
                <ItemStyle CssClass="IV_MasterGrid_GroupHeader" />
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 

Here's my C# code-behind:

protected void grdViewInventory_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    siteID = ApplicationDTO.GetSiteID();
    grdViewInventory.DataSource = BLL.GetInventoryHeader(siteID).GroupBy(x => x.DataKey).Select(y => y.First()).OrderBy(z => z.Building);
}
 
protected void grdViewInventory_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
    //Hides the expand/collapse column
    if (e.Column is GridExpandColumn)
    {
        e.Column.Visible = false;
    }
}
 
protected void btnExportToExcel_Click(object sender, EventArgs e)
{
    grdViewInventory.ExportSettings.OpenInNewWindow = true;
    grdViewInventory.ExportSettings.ExportOnlyData = true;
    grdViewInventory.ExportSettings.IgnorePaging = true;
    grdViewInventory.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;
    grdViewInventory.MasterTableView.Items[0].Expanded = true;
    RadGrid rgNestedViewInventory = (RadGrid)grdViewInventory.MasterTableView.Items[0].ChildItem.FindControl("rgNestedViewInventory");
    rgNestedViewInventory.Rebind();
    grdViewInventory.MasterTableView.HierarchyDefaultExpanded = true;
    grdViewInventory.MasterTableView.ExportToExcel();
}
 
protected void rgNestedViewInventory_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    RadGrid rgChild = (RadGrid)sender;
    GridNestedViewItem nesteditem = (GridNestedViewItem)rgChild.NamingContainer;
    string dataKey = Convert.ToString(nesteditem.ParentItem.GetDataKeyValue("DataKey"));
    (sender as RadGrid).DataSource = BLL.GetInventory(siteID).Where(x => x.DataKey == dataKey).OrderBy(y => y.PropertyNumber);
}

Shawn
Top achievements
Rank 1
 answered on 28 Sep 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?