This is a migrated thread and some comments may be shown as answers.

Buttons and NumericTextBox in form

3 Answers 246 Views
Form
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Veteran
Andrey asked on 30 Jun 2020, 01:41 PM

Hi, Dev Team!

I have two questions:

1. How i can hide "Clear" button?

2.How i can hide annoing ".00" after integer number in NumericTextBox field? 

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 01 Jul 2020, 06:33 AM

Hello Andrey,

The buttons of the Form can be customized through the buttonsTemplate option as follows:

buttonsTemplate: "<button class='k-button'>Submit</button>",
The NumericTextBox field options can be configured through the item.editor and item.editorOptions as follows:

items: [
  { field: "Age", editor: "NumericTextBox", editorOptions: { format: "n0" } }
]  

Here is a Dojo example where both of the above options are demonstrated.

I hope this helps.

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Andrey
Top achievements
Rank 1
Veteran
answered on 03 Jul 2020, 12:24 PM

Dimitar, thank you!

So for execute code after press button i need to provide ID and bind some action by ID like

buttonsTemplate: "<button class='k-button' id='myButton'>Submit</button>"

 

document.querySelector("#myButton").onclick = function () {}

0
Dimitar
Telerik team
answered on 06 Jul 2020, 04:16 AM

Hello Andrey,

In general, when adding a submit button to the form through the template will cause the form to be submitted as usual when this button is clicked. In case you would like to prevent the standard form submit and instead send an ajax request, you can:

1) Proceed as you have already suggested by adding a click handler, calling ev.preventDefault() and then sending an ajax request.

2) Utilize the Form submit event, prevent it, and send an ajax request:

 $("#exampleform").kendoForm({        
  ...       
  buttonsTemplate: "<button id='my-button' class='k-button'>Submit</button>",              
  submit: function(ev) {
    ev.preventDefault();
              
    var model = ev.model;                  
    console.log(model);
    // send ajax
  }
});        

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Form
Asked by
Andrey
Top achievements
Rank 1
Veteran
Answers by
Dimitar
Telerik team
Andrey
Top achievements
Rank 1
Veteran
Share this question
or