sButtonText not working when extending editor_create
sButtonText not working when extending editor_create
jammyb
Posts: 12Questions: 3Answers: 0
I have the following code, however this results in a Create form with two buttons displaying the text "Create". How do I change this text? Is this a bug?
[code]
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{
"sExtends": "editor_create",
"sButtonClass": "editor_create",
"editor": editorGridMaterialsDT,
"formButtons": [
{
"label": "Create",
"sButtonText": "Create & Add Another",
"className": "create_next",
"fn": function (e) {
this.submit( function () {
$('a.editor_create').click();
}, null, null, false );
}
},
{
"label": "Create",
"className": "create",
"fn": function (e) {
this.submit();
}
}
]
},
[/code]
Thanks in advance for your help.
[code]
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{
"sExtends": "editor_create",
"sButtonClass": "editor_create",
"editor": editorGridMaterialsDT,
"formButtons": [
{
"label": "Create",
"sButtonText": "Create & Add Another",
"className": "create_next",
"fn": function (e) {
this.submit( function () {
$('a.editor_create').click();
}, null, null, false );
}
},
{
"label": "Create",
"className": "create",
"fn": function (e) {
this.submit();
}
}
]
},
[/code]
Thanks in advance for your help.
This discussion has been closed.
Replies
Allan
[code]
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{
"sExtends": "editor_create",
"sButtonClass": "editor_create",
"editor": editorGridMaterialsDT,
"formButtons": [
{
"label": "Create & Add Another",
"sButtonText": "Create & Add Another",
"className": "create_next",
"fn": function (e) {
this.submit( function () {
$('a.editor_create').click();
}, null, null, false );
}
},
{
"label": "Create",
"className": "create",
"fn": function (e) {
this.submit();
}
}
]
},
[/code]
Still both buttons display 'Create'.
I can send over a beta version of Editor 1.3 if you like - that resolves this issue? I couldn't see a purchased or trial license for your account - are you using Editor downloaded from a different account? Could you let me know which one, if so, so I can update my records and ensure you get the correct level of support!
Allan
The address I purchased the Editor with was james at code 99.
Thanks.
I believe the line 87 should be changed from
[code]if ( store[i].DT_RowId === 'row_'+i ) {[/code]
to
[code]if ( store[i].DT_RowId === id ) {[/code]
Would you like a beta copy of 1.3 which resolves this issue?
Regarding the localStorage example - I think it is actually correct at the moment because the id is stored with the `row_` prefix: `"DT_RowId": 'row_'+store.length, ` . Unless I'm missing something?
Thanks,
Allan
Please do send me the beta copy of 1.3.
The problem is, it always returns i=0. Step through it for an id='row_1' at index 1. First time through the loop, i=0, so the if statement is if(store[0].DT_RowId === 'row_0'). In my case, this is true, however it's not the index of the id I'm after.
LocalStorage - yup I see the point. It should be checking `'row_'+id` - oops! Thanks for pointing that out. Will be fixed in the 1.3 (although not the beta package I've just sent over...).
Allan
With regards to the LocalStorage example, id gets sent through as 'row_1', so it just needs to be id, not 'row_'+id. (I made the same mistake initially) :)
Allan
i need the same 'create & add another' functionality. Of course I tried to get the code above to do the work. To work around the bug mentioned above I relocated the buttons:
[code]
editor = new $.fn.dataTable.Editor({
"ajaxUrl": "ajax_dummy",
"domTable": "#table-view",
"idSrc": "0",
"dbTable": "<%= $query_id %>",
"fields": aoFields
});
$('#table-view').dataTable({
"aoColumns": aoColumns,
"aaData": aaData,
"bDeferRender": true,
"iDisplayLength": 100,
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": 600,
"bJQueryUI": true,
"sDom": "Tfrtip",
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor,
"formButtons": [
{
"label": "Create",
"className": "create",
"fn": function (e) {
this.submit();
}
},
{
"label": "Create & Add Another",
"sButtonText": "Create & Add Another",
"className": "create_next",
"fn": function (e) {
this.submit( function () {
$('a.editor_create').click();
}, null, null, false );
}
}
] },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
});
[/code]
Now I see the two buttons I want (left button 'Create & Add Another'; right button 'Create') and the right button works as expected. It creates a new data row and closes the editor. But the left button does not. If you click it, a new row is created and the editor remains open, BUT you can't created another line. I am able to change the field values as expected (although I'd like to see them empty) but clicks on BOTH buttons have no effect. They're just doing nothing at all. Why is that?
I also tried different code:
[code]
TableTools.BUTTONS.editor_create.formButtons.push({
"label": "Create & Add Another",
"className":"btn btn-link",
"fn": function () {
this.submit( function () {
$('a.editor_create').click();
}, null, null, false );
}
});
editor = new $.fn.dataTable.Editor({
"ajaxUrl": "ajax_dummy",
"domTable": "#table-view",
"idSrc": "0",
"dbTable": "<%= $query_id %>",
"fields": aoFields
});
$('#table-view').dataTable({
"aoColumns": aoColumns,
"aaData": aaData,
"bDeferRender": true,
"iDisplayLength": 100,
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": 600,
"bJQueryUI": true,
"sDom": "Tfrtip",
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
});
[/code]
and it's the same behaviour.
Would you please tell me what I'm doing wrong?
Regards,
Mathias
Allan
No, I'm new to web development and I didn't know the 'a.' in [code] this.submit( function () {
$('a.editor_create').click();
}, null, null, false );
}[/code] stood for a HTML link class name. So I just used the great firefox web development tools, looked up the name of the class of my button, wrote this class name for 'a' and voila: it worked.
Thanks for your help anyway.
Mathias
Allan