Create submit 0 or null as field value

2 posts, 0 answers
  1. MiracleMan
    MiracleMan avatar
    11 posts
    Member since:
    Aug 2015

    Posted 05 Oct 2015 Link to this post

    Hello all, 

    I have grid which displays a group of records.  Then some custom actions to perform on this records. One of the custom actions will open a popup window which displays another grid with child information about the original table.  I'm doing this by passing a custom query string with the parent key.

     In this child table, when I try to create a new record, the foreign key that is passing to the controller is 0 event though when editing, the binding will show the correct value. Through jquery I'm able to read the parentID and put it in a hidden field in the child screen, but when submitting, is goes as 0 again even though it has a number on it.  The only way I'm able to solve the issue is by passing a value directly to the model in the child window in the OnEdit event like this:


        e.model.set("GroupID", $("#txtGroupID").val());


    Anyone knows why is passing a 0 value although I'm assigning a value for it: $("#GroupID").val($("#txtGroupID").val());

    Any recommendations?

  2. Rosen
    Rosen avatar
    3253 posts

    Posted 07 Oct 2015 Link to this post

    Hello MiracleMan,


    The behavior you have described is caused by the fact that setting value via JavaScript to an input element will not trigger its change event. As you know the grid's edit form is bound to the model instance via our MVVM, which tracks user input to the UI elements by handling the appropriate change events. In this case the binder is not notified and the value which you have set to the element is not set into the model - this is why when pushed to the server, value is not the one you have set manually.


    In order to correct this you should either use the set method of the model (as you have already mentioned) or manually trigger the change event of the input element (note that this element should have the appropriate data-binding attribute set).



    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