JavaScript runtime error when updating radgrid source

4 posts, 0 answers
  1. Casper
    Casper avatar
    24 posts
    Member since:
    Mar 2015

    Posted 08 Apr 2015 Link to this post

     

    I have a radgrid that inherits it hierarchy from a System.Data.DataSet. When I make a change I update the database from which the DataSet gets its data and rebuild the grid as this answer suggests. The first time the update always runs as expected and updates in the grid. After that after varying amount of changes( I can't seem to figure out exactly which one causes this) I get the following error:

    JavaScript runtime error: Unable to get property 'get_element' of undefined or null reference

     

    I hope you are able to help

     

    /Casper

  2. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 13 Apr 2015 Link to this post

    Hello Casper,

    Can you please verify that you are not using DataBind() to bind the grid? Please note that performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
    Declarative DataSource
    Advanced Data Binding


    Here is a live demonstration for declarative binding of a hierarchy:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/insert-update-delete-hierarchy/defaultcs.aspx
    And also programmatic:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/programmatic-hierarchy/defaultcs.aspx


    You can also check the following sample for CRUD operations:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/insert-update-delete-hierarchy/defaultcs.aspx

    Hope this helps.

    Regards,
    Eyup
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Casper
    Casper avatar
    24 posts
    Member since:
    Mar 2015

    Posted 13 Apr 2015 in reply to Eyup Link to this post

    I am setting the radgrid's datasource to my dataset. I wasn't using the DataBind()-function, but I tried inserting it after the datasource assignment and suddenly couldn't get to a hierarchy level above 2 even though i could before(and can if it is removed).

    I've seen the links you've provided. I'm not sure if I can use them in the same way. I initially thought this was a generic problem, but it might be specific to my case. I have a rather large set of tasks. each task can have a subtask and each subtask can have another subtask(this extends to an arbitrary large depth). The way this hierarchy currently is implemented is that each task have a column containing their parent id, and the root of the hierarchy have null as a parent.
    The current implementation, that gives the first mentioned error, is that I programatically create the dataset and the relations between the tables and then rebuild the entire grid. On an update I manually update my database with the the new values and build it again.
    As mentioned earlier the application throws an exception if it is updated more than 1 time, what i find curious is that when the application is restarted the grid is updated and no new exception is thrown until 2 or more alterations have been made

  5. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 16 Apr 2015 Link to this post

    Hi Casper,

    This might be something related to the ViewState then. If you are changing the columns structure dynamically, you should do that according to the steps provided in the following article:
    http://www.telerik.com/help/aspnet-ajax/grid-changing-structure-dynamically.html

    Regards,
    Eyup
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top