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

Get value of the cell I edit

5 Answers 1721 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mateusz
Top achievements
Rank 1
Mateusz asked on 04 Nov 2015, 12:09 PM

Hi,

 I have a Grid with batch editing. When I start to edit cell I have to capture the value of it (with changes made while editing) to send it to the controller. 

 How can I get this value? I have managed to get the cell itself with following javascript but it does not hold the value:

 

function cellData() {
     var grid = $("#CustomerOrderPosition").data('kendoGrid');
     var cellId = grid._cellId;
     var cell = document.getElementById(cellId);
 }

5 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 05 Nov 2015, 02:17 PM
Hello Mateusz,

In order to get the value for the cell before it is changed you can handle the edit event for the grid. Check out the following dojo sample that illustrates the approach:



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mateusz
Top achievements
Rank 1
answered on 05 Nov 2015, 02:34 PM

Hi Viktor,

 What about value after I change it? I need this functionality for autocomplete that I use in Grid, so when I type in new character I need new a method that will pass value to my custom editor.

 

0
Viktor Tachev
Telerik team
answered on 06 Nov 2015, 12:36 PM
Hi Mateusz,

If you are using a custom editor in one of the column of the grid you can use an approach similar to the one illustrated in the following online example.



Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mateusz
Top achievements
Rank 1
answered on 06 Nov 2015, 02:02 PM

this example is nothing new to me and it just loads static data. What I need is an example of body for method onAdditionalData that is used in code below that makes server side filtering possible:

Full example from Telerik

<%= Html.Kendo().AutoComplete()
          .Name("products")
          .DataTextField("ProductName")
          .Filter("contains")
          .MinLength(3)
          .HtmlAttributes(new { style = "width:250px" })
          .DataSource(source => {
              source.Read(read =>
              {
                  read.Action("GetProducts", "Home")
                      .Data("onAdditionalData");
              })
              .ServerFiltering(true);
          })
    %>
0
Viktor Tachev
Telerik team
answered on 10 Nov 2015, 08:21 AM
Hello,

You can use custom editor by adding For to the name of the AutoComplete widget. Then you can use jQuery to get the value entered by the user and return it in the onAdditionalData function.


function onAdditionalData() {
    return {
        text: $("#products").val()
    };
}


Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Mateusz
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Mateusz
Top achievements
Rank 1
Share this question
or