Editor with Bootstrap
Editor with Bootstrap
johnd28714
Posts: 3Questions: 0Answers: 0
Hi All,
I'm using the DataTables editor with Bootstrap and all was working well i.e the table and the editor form were rendered with Bootstrap visuals.
I was using the TableTools to add the create/edit/remove buttons and all worked well. I then switched to inline edit/delete buttons using the example code and when I did that the Editor form is no longer styled with the Bootstrap visuals ie the Button has default styling etc.
Here's the code for the edit button:
// Edit record
$('#example').on('click', 'a.editor_edit', function (e) {
e.preventDefault();
editor.edit(
$(this).parents('tr')[0],
'Edit record',
{ "label": "Update", "fn": function () { editor.submit() } }
);
} );
I'm assuming there is sometype of css class issue going on but am at a loss as to how to fix it.
Suggestions ?
Thanks in advance,
John
I'm using the DataTables editor with Bootstrap and all was working well i.e the table and the editor form were rendered with Bootstrap visuals.
I was using the TableTools to add the create/edit/remove buttons and all worked well. I then switched to inline edit/delete buttons using the example code and when I did that the Editor form is no longer styled with the Bootstrap visuals ie the Button has default styling etc.
Here's the code for the edit button:
// Edit record
$('#example').on('click', 'a.editor_edit', function (e) {
e.preventDefault();
editor.edit(
$(this).parents('tr')[0],
'Edit record',
{ "label": "Update", "fn": function () { editor.submit() } }
);
} );
I'm assuming there is sometype of css class issue going on but am at a loss as to how to fix it.
Suggestions ?
Thanks in advance,
John
This discussion has been closed.
Replies
Are you able to link to a test case please? How the editing interface is triggered shouldn't have any baring how the style of it - it should be that the bootstrap styling will still appear int he editing interface, as long as the bootstrap integration is still complete.
Allan
The input boxes also don't even get a type, let alone a class...they just show up as [code][/code]
Hope some of that information helps
psenechal - I notice your Editor trial ended a few months ago. Are you still evaluating Editor? Are there any questions about the licensing that you have?
Allan
[code]{
"mData": null,
"bSortable": false,
"sClass": "center",
"sWidth": "50px",
"sDefaultContent": ' '
}[/code]
The actual calls look like this:
[code]// New record
$("a.editor_create").on("click", function (e) {
e.preventDefault();
editor.create(
"Create a new Report Type",
{ "label": "Add", "fn": function () { editor.submit() } }
);
});
// Edit record
$("#reporttypeTable").on("click", "a.editor_edit", function (e) {
e.preventDefault();
editor.edit(
$(this).parents('tr')[0],
"Edit Report Type",
{ "label": "Update", "fn": function () { editor.submit() } }
);
});
// Delete a record
$("#reporttypeTable").on("click", "a.editor_remove", function (e) {
e.preventDefault();
editor.message("Are you sure you wish to delete this Report Type?");
editor.remove(
$(this).parents("tr")[0],
"Delete Row",
{ "label": "Delete", "fn": function () { editor.submit() } }
);
});[/code]
We're still evaluating if it's going to work for our solution. I had downloaded it quite a while ago and we're just now starting to test our interface updates with it. I'll have to go through corporate purchasing if we decide to purchase a license.
You need to add the className option so it is applied to the button.
[code]
{
"label": "Add",
"className": "btn btn-primary",
"fn": function () { editor.submit() }
}
[/code]
> We're still evaluating if it's going to work for our solution
Okay - let me know if you have any additional questions.
Allan
Thanks so much!
[code]
fieldTypes.text = $.extend( true, {}, baseFieldType, {
"create": function ( conf ) {
conf._input = $('')[0];
return conf._input;
}
} );
[/code]
It should be:
[code]
fieldTypes.text = $.extend( true, {}, baseFieldType, {
"create": function ( conf ) {
conf._input = $('')[0];
return conf._input;
}
} );
[/code]
which will be in 1.2.3, or you can modify your local version at the moment.
Allan
I use Select2 (http://ivaynberg.github.com/select2/) for my dropdowns. I'm trying to apply it to dropdowns in the editor by using the onOpen event. Unfortunately, the editor seems to be drawing the dropdown after the script executes because the first time the editor opens, the dropdowns aren't affected, but the second time it opens, they are.
Do you have any suggestions on how to get a jQuery call for this type of scenario to work? I suppose I could create a custom data type (I created one for spinner buttons), but it would be nice to use the built in select type.
Any suggestions are greatly appreciated. Thanks!
Having said that, `onOpen` probably isn't working for you due to the async animation. If the animation were to be removed, it would likely work. What you could do is use the `node` method ( http://editor.datatables.net/docs/current/Editor.html#node ) to get the container for the select input in `onOpen` and apply it to that directly - I suspect it isn't working the first time as it either isn't displayed or not yet in the DOM.
Allan
Thanks for the suggestion!
Allan
[code]
"onOpen": function (e) {
setTimeout(function() {
$("select").select2({
width: "element"
});
}, 250);
}
[/code]