Custom Table Form clear after Submit.

Andy Rokicki asked on June 11, 2015 21:55

I have added Custom table form, and it it is working. Functionality that I can't seem to find is how to tell it to clear once user clicks "Submit" button.

Recent Answers


Joshua Adams answered on June 11, 2015 22:30

There should be a property on a custom table form for clearaftersave which is a boolean. The property won't be available on the configuration, so you will have to clone the control and place it in the code behind or create a custom layout on the control and add that property to the custom table form. Not sure if you are using the built in webpart for Kentico, worst case, you can clone that webpart, and add that property to the control setup and you should be good to I believe.

0 votesVote for this answer Mark as a Correct answer

Andy Rokicki answered on June 11, 2015 22:40

Thanks I have cloned CutomTableForm.asx.* but I can't find clearaftersave . I am using Kentico 8.0.

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on June 11, 2015 22:44

Looks like that control doesn't have the property...two options here then. Either change your control to use a base dataform for kentico(cms:DataForm), or create an on aftersave event and set the form.Data = null? That should work I think. Also clear the ItemID and maybe the info. Not sure, you may have to play around with that just to make sure. Second option may be easier...just because you have all of the other stuff there, you just need to hook up that event.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on June 11, 2015 23:15

Take a look at this webpart I created in the Marketplace. It has this functionality already built in.

0 votesVote for this answer Mark as a Correct answer

Andy Rokicki answered on June 12, 2015 16:39

Joshua , Have tried setting form.Data = null but it did not clear fields. Using cms:DataForm I am not sure how to set custom table (Alternative form) as my data source.

Brenden, I have tried your control, but on submit the DisplayFormAfterSubmit hides the fields. My intent is on submit fields stay visible but they are cleared(same as when the form first loads).

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on June 12, 2015 16:57

Andy, try to call the ReloadData() method as well and that should work.

0 votesVote for this answer Mark as a Correct answer

Andy Rokicki answered on June 12, 2015 17:38

Ok I have added:

 private void ClearData()
    {
        customTableForm.Data = null;
        DataRow NewRow = customTableForm.DataRow;
        customTableForm.LoadData(NewRow);
    }

And call ClearData() in OnAfterSave event, That has clear form fields after submit clicked.

I am all set now. Thanks for pointing me in the right direction. Andy r.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.