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

Radgrid - Get Value of Cells in Batch Edit Mode.

2 Answers 845 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 19 Dec 2014, 02:11 PM
Hi..

I have a radgrid with a column that I'm entering a reference number that I wish to use to extract a corresponding row value. This reference value is not required to be stored so I only need to access the entry whilst the cells are in edit mode (red updated symbol) I wish to use the extracted value to plot a route via google maps.. and the reference will be a number corresponding to the waypoint order. How can I extract a list of strings of postcode column based on numerical value / null value in map column.

<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowPaging="True" PageSize="10" EnableViewState="True"
        AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemUpdated="RadGrid1_ItemUpdated"
        OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound"
        OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound"
        CellSpacing="0" Skin="Windows7">
           <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="ID, PK"
            HorizontalAlign="NotSet" AutoGenerateColumns="False" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
11                 AllowAutomaticUpdates="False" EditMode="Batch">
            <BatchEditingSettings EditType="Cell" />
            <Columns>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
                    UniqueName="Name" ColumnEditorID="GridTextBoxColumnEditorEditor1">
                </telerik:GridBoundColumn>
                <telerik:GridHyperLinkColumn DataNavigateUrlFields="Postcode" HeaderText="Location" SortExpression="Location"
                    DataTextField="Location" UniqueName="Location" DataNavigateUrlFormatString="http://maps.google.co.uk/maps?q={0}">
                </telerik:GridHyperLinkColumn>
                <telerik:GridNumericColumn DataField="Map" HeaderText="Map" SortExpression="Map"
                    UniqueName="Map" Display="false" ColumnEditorID="GridTextBoxColumnEditorMap">
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="Sample" HeaderStyle-Width="300px" HeaderText="Equipment" SortExpression="Sample"
                    UniqueName="Equipment" ColumnEditorID="GridTextBoxColumnEditorEditor3">
                </telerik:GridBoundColumn>>
                <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                    UniqueName="Delete">
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

protected void rut_Click(object sender, EventArgs e)
        {
          string v;
           foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
           {
               if (item.FindControl("Map") != null)
               {
                   v = (item.FindControl("Map") as TextBox).Text;
               }
           }

            ClientScript.RegisterStartupScript(this.GetType(), "yourMessage", "alert('" + v + "');", true);
        }

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 24 Dec 2014, 09:56 AM
Hello Dave,

The changes made on client-side with Batch Editing are not available on server-side, except when the "Save Changes" button is clicked or when the BatchEditingManager is used for manually initiate saving. Detailed information on Batch Editing is available in the following help article:
The only thing that I could suggest in your scenario with an external button is to handle its client-side click event, traverse through all items and retrieve the "Map" value:
function buttonClick(sender, args) {
    var grid = $find("<%=RadGrid1.ClientID%>");
    var tableView = sender.get_masterTableView();
    var batchManager = sender.get_batchEditingManager();
    var items = tableView.get_dataItems();
    var mapValues = [];
    for (var i = 0; i < items.length; i++) {
        var mapCell = items[i].get_cell("Map");
        var mapValue = batchManager.getCellValue(mapCell);
        mapValues.push(mapValue);
    }
    // save the value in a HiddenField control for example
}

The above is just a suggestion and you should decide whether or not it is applicable in your scenario.
 


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Dave
Top achievements
Rank 1
answered on 20 Jan 2015, 07:28 AM
Thanks Konstantin.. 
Tags
Grid
Asked by
Dave
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Dave
Top achievements
Rank 1
Share this question
or