Get value of the cell I edit

6 posts, 0 answers
  1. Mateusz
    Mateusz avatar
    3 posts
    Member since:
    Oct 2015

    Posted 04 Nov 2015 Link to this post

    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);
     }

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 05 Nov 2015 Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Mateusz
    Mateusz avatar
    3 posts
    Member since:
    Oct 2015

    Posted 05 Nov 2015 in reply to Viktor Tachev Link to this post

    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.

     

  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 06 Nov 2015 Link to this post

    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
  6. Mateusz
    Mateusz avatar
    3 posts
    Member since:
    Oct 2015

    Posted 06 Nov 2015 Link to this post

    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);
              })
        %>
  7. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 10 Nov 2015 Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready