Reputation: 87
I'm using JS-GRID. How can i set default value to input?
I tried following code. But not successful
fields: [
{ name: "addresse", type: "text", width: 500, validate: "required",
insertValue: function(){
return "My Default value";
}
},
]
Upvotes: 1
Views: 4475
Reputation: 2313
Yes, this works, but probably even better would be to override insertTemplate
instead custom implementation (in this case you don't need to take care of insertValue
).
insertTemplate: function() {
var $result = jsGrid.fields.text.prototype.insertTemplate.call(this); // original input
$result.val('My Default Value');
return $result;
}
As described in this issue on GitHub https://github.com/tabalinas/jsgrid/issues/471
Upvotes: 3
Reputation: 87
Okay. My problem has solved.
insertTemplate: function() {
return $("<input>").attr("type", "text").attr("value", "My Default value");
}
Upvotes: 1