Grid API method trigger help

12 posts, 0 answers
  1. John
    John avatar
    24 posts
    Member since:
    Nov 2011

    Posted 09 Feb 2012 Link to this post

    We have a grid on the browser page that works great BUT we want it to save every time they delete a record, and then to notify them the record was saved of course. (displaying the same page of data).

    Issue:
    We cannot seem to get the grid to refresh. We see the API function but our interpretation of the docs is not working for us.

  2. John
    John avatar
    24 posts
    Member since:
    Nov 2011

    Posted 09 Feb 2012 Link to this post

    I enter this in the console of the browser dev tool. - - - m = jQuery('#grid').data('kendoGrid') 
    m.saveChanges()
    - - -

    Then I get this result.

    - - - 

    undefined

    - - -

    the grid is a fully functional grid with a toolbar and a "Save changes" button that is working.

  3. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    1954 posts
    Member since:
    Dec 2014

    Posted 14 Feb 2012 Link to this post

    Hello John,

    You can set autoSync: true in DataSource configuration in order to achieve this behavior as demonstrated on the jsFiddle bellow:
    http://jsfiddle.net/rusev/Rhz72/

    Greetings,
    Nikolay Rusev
    the Telerik team

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  4. Mike
    Mike avatar
    8 posts
    Member since:
    Jan 2012

    Posted 27 Feb 2012 Link to this post

    Ok well... autosync doesn't work for the delete button that appears in the grid, at least not with my version of kendo (open source version).  I have a grid and the delete button removes the row but doesn't call the destroy transport.  I debugged it and when the datasource creates the ModelSet it doesn't set the autosync flag of the ModelSet.  So when the modelset is created it's defaulted to autosync = false.  When you go to delete the row is removed but ModelSet checks for "autosync" and skips the sync because it's always false.

  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    1954 posts
    Member since:
    Dec 2014

    Posted 29 Feb 2012 Link to this post

    Hello Mike,

    autoSync: true seems to be working on the jsFiddle attached to my previous post.

    Regards,
    Nikolay Rusev
    the Telerik team

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  6. Mike
    Mike avatar
    8 posts
    Member since:
    Jan 2012

    Posted 29 Feb 2012 Link to this post

    HI Nikolay,

    Yes it MIGHT seem like your autosync is working but I would be suspect at least for delete buttons.   I know the create and updates commands work even if I do not specify a setting for autosync,  But I could not get delete buttons to work on remote datasources. When I click delete on the grid button, the grid removes the item but the items come back if I refresh.  Just like your fiddle and all of the KendoUi.com demos, deletes are not persisted.  Of course I expect this to happen in your demos or they wouldn't work very well if everyone could delete the demo data.  

    I have set  autosync to true on my datasource and editable is set to true on my grid.  Clicking delete removes the item off my grid... but the destroy url is never called.  When I debugged it I noticed that the datasource has set autosync=true but the underling object called modelset still has the default set of autosync = false. so the modelset does not call sync after it removes the item.    So when I refresh the items come back.  I have put a break point in my server delete controller so I know it's not getting called.  Again I have the open source version of kendo so maybe it's fixed in a new version I don't have.  The only way I could get this to work was to make my own button using a kendo template, getting the item id off the grid and calling remove and sync on the datasource manually.

    thanks

  7. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    1954 posts
    Member since:
    Dec 2014

    Posted 05 Mar 2012 Link to this post

    Hello Mike,

    Please check the video posted bellow:
    http://screencast.com/t/sfQP72exlPKD

    autoSync seems to be working properly. The jsFiddle is the last I've posted in this thread.

    All the best,
    Nikolay Rusev
    the Telerik team

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  8. Randy
    Randy avatar
    1 posts
    Member since:
    Mar 2011

    Posted 28 Mar 2012 Link to this post

    How did you get it to work manually?

    I added a custom command button and was successfully able to delete the object using dataSource.remove(dataItem). This fires the destroy event on the server and removes the item from the grid. The next time i refresh the item is still there even though it has been removed from the database.

    Is there some caching going on here that is causing this behavior. If i put a breakpoint in the read methods it doesnt hit on every refresh.

  9. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    1954 posts
    Member since:
    Dec 2014

    Posted 02 Apr 2012 Link to this post

    Hello Randy,

    There is a jsfiddle with working example in this thread. The video is captured against this example. There is no caching involved in the example. I guess for your scenario you should verify whether on sync deleted items are actually deleted from the data storage.

    You can also check the following repositories with fully working Grid CRUD operations:
    https://github.com/telerik/kendo-examples-asp-net-mvc
    https://github.com/telerik/kendo-examples-asp-net

    Greetings,
    Nikolay Rusev
    the Telerik team

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  10. Sergey
    Sergey avatar
    1 posts
    Member since:
    May 2012

    Posted 15 May 2012 Link to this post

    Solution:
    replace new version Kendo UI to old (from example where is it work):
    <script type='text/javascript' src="http://cdn.kendostatic.com/2011.3.1407/js/kendo.all.min.js"></script>

    To support: Find this problem in the new version Kendo UI.

  11. Johsua
    Johsua avatar
    2 posts
    Member since:
    Feb 2012

    Posted 15 May 2012 Link to this post

    Hi nikolay,
    waiting for your comment on sergey's post.

  12. Mike
    Mike avatar
    8 posts
    Member since:
    Jan 2012

    Posted 15 May 2012 Link to this post

    This was clearly broken in kendo.all in earlier versions.   I have the code so I can post it if you like.    However you guys fixed it in later versions exactly like I described in my earlier post.    The autosync flag is now being pasted to the modelset class. The first version I've used where the bug is fixed is  v2011.3.1407.  I'm not sure when it was fixed but v2011.3.1407  has the fix that makes autosync work.  

    However with the latest versions of kendo (v2012.1.503)...  all of the relative code has been reworked and I have not tested it.   I'm assuming it's still fixed. The bug I'm talking about is... delete command on a grid not calling sync even when autosync is set to true.   So if your having delete problems make sure your kendo.all version is at least v2011.3.1407 or greater.

     

Back to Top