This is a migrated thread and some comments may be shown as answers.

MasterTableView.get_selectedItems() returns empty

2 Answers 214 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 24 Oct 2013, 12:16 PM
I have a rad grid with check boxes.
I have a rad combo box that controls what data is returned to the grid.
I have a button that processes the checked items.
The first time the data is loaded, selected items are present and processed.
If I change the combo box selection, the data loaded is correct but the selected items always returns an empty list.

The Grid
<MasterTableView CommandItemDisplay="Top" AllowCustomPaging="True" AllowPaging="True"
                        TableLayout="Fixed" ClientDataKeyNames="AssetId,MacId" PagerStyle-PageSizes="25;50;75;100">
                        <CommandItemSettings ShowAddNewRecordButton="False"></CommandItemSettings>
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridClientSelectColumn HeaderStyle-Width="3em" UniqueName="ClientSelectColumn">
                                <HeaderStyle Width="3em" />
                            </telerik:GridClientSelectColumn>
                            <telerik:GridBoundColumn DataField="MacId" HeaderText="Mac Id" UniqueName="MacId">
                                <HeaderStyle Width="75px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="PoleId" HeaderText="Pole" SortExpression="PoleId"
                                UniqueName="PoleId" HeaderStyle-Wrap="false" HeaderStyle-Width="75px">
                            </telerik:GridBoundColumn>

The Data Source

<asp:LinqDataSource ID="StatusDataSource" runat="server" ContextTypeName="EnterpriseWeb.DataContracts.Diagnostics.DiagnosticsDataContext"
    EntityTypeName="" OrderBy="Weight" Select="new (StatusId, Description, ShowByDefault)"
    TableName="StatusCodeRows" OnSelected="StatusDataSource_Selected">
</asp:LinqDataSource>

The JavaScript

var Items = MasterTableView.get_selectedItems();
 
if (Items.length > 0)
{
    var SelectedAssetIds = [];
 
    $.each(Items, function (i, Item) {
        SelectedAssetIds.push(Item.getDataKeyValue("AssetId"));
    });
 
    var List = SelectedAssetIds.join("|");
    OpenRadWindow(BaseUrl + "Html/WorkOrders/WorkOrdersCreatepage.aspx?InstallationId=" + InstallationId + "&Assets=" + List, "WorkOrderCreateWindow");
}



 

2 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 29 Oct 2013, 12:07 PM
Hi Ed,

I created a sample project form the provided description, however I was unable to replicate the issue. You would find the project as an attachment. There is a RadComboBox and on its OnSelectedIndexChanged event the RadGrid is rebound. The number of selected items is returned when the button on the page is clicked.

Give this project a try and let me know if it is working for you. I would appreciate it if you could modify the sample in a way that the problematic behavior is replicated and send it back in a support ticket. This would enable us to further investigate the issue and provide appropriate solution.

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Ed
Top achievements
Rank 1
answered on 31 Oct 2013, 11:45 AM
It works, now.

The change I made was in the pageLoad method, wherein I was assigning a variable to the grid's MasterTableView.
MasterTableView = $find("<%= HistoryGrid.MasterTableView.ClientID %>");

Changed to
MasterTableView = $find("<%= HistoryGrid.ClientID %>").get_masterTableView(); 
Tags
Grid
Asked by
Ed
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Ed
Top achievements
Rank 1
Share this question
or