Reset Single Field to Initial Value

6 posts, 0 answers
  1. Bill
    Bill avatar
    23 posts
    Member since:
    Jun 2019

    Posted 15 Mar Link to this post

    Hi There,

    We are using the Kendo React Form library. Is it possible to reset a single field to the initial value that the form supplies? I see the way to reset the entire form, but we are looking to include a reset button next to each input field that would reset the field to it's initial value and also inform the form that it has not been modified.

  2. Bill
    Bill avatar
    23 posts
    Member since:
    Jun 2019

    Posted 15 Mar in reply to Bill Link to this post

    I think I figured it out using fieldRenderProps.onChange({ value: initialValue }).
  3. Stefan
    Admin
    Stefan avatar
    3070 posts

    Posted 16 Mar Link to this post

    Hello, Bill,

    Yes, this is the correct way to reset the value of a single field.

    This can also be done on a Form level, by passing the field name:

    https://www.telerik.com/kendo-react-ui/components/form/advanced-scenarios/#toc-changing-the-field-value

    Regards,
    Stefan
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

  4. Bill
    Bill avatar
    23 posts
    Member since:
    Jun 2019

    Posted 16 Mar in reply to Stefan Link to this post

    I have a follow up question. Is there a way to reset the fieldrenderprops so the form sees it as having not been modified or touched?
  5. Bill
    Bill avatar
    23 posts
    Member since:
    Jun 2019

    Posted 16 Mar in reply to Bill Link to this post

    Second follow up :-).

    Is there a way to use promises or something like that to detect a successful form save in order to disable the save button

  6. Stefan
    Admin
    Stefan avatar
    3070 posts

    Posted 17 Mar Link to this post

    Hello, Bill,

    Regarding the questions:

    1) Is there a way to reset the fieldrenderprops so the form sees it as having not been modified or touched - Currently, they will be updated as the field value is indeed modified. If we do not change it, this can lead to wrong information in many cases.

    2) Is there a way to use promises or something like that to detect a successful form save in order to disable the save button - The Form save (the request to the server) is made by the developer, which means that the developer can use the callback from the server. The KendoReact Form is not making requests to save the data internally, this is why we have no information when the Form is saved in order to provide such a callback.

    In general, we recommend submitting new tickets/forum posts for different questions as for example someone may be searching for the same answer, but it will be difficult to find when it is answered in a different topic.

     

    Regards,
    Stefan
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top