Problem with buttons and delete.

Problem with buttons and delete.

GeXXGeXX Posts: 3Questions: 0Answers: 0
edited August 2012 in General
I guess I'm stupid. Givin' up.

Whatever i try it messed up. I try your examples. It works. But every time i want to change
some simply things, it doesnt work.

1st case:
I can't delete a entry (editor). If i remove the length-test
[code]
else if ( o.data.title.length >= 20 ) {
this.error('title', 'The browser name length must be less that 10 characters');
return false;
}
[/code]
it works. What's wrong?
Firefox debug: TypeError: o.data.title is undefined.
But the length-check works while editing.


2nd case:
I can't add any other buttons like "copy". After inserting "copy" i dont get any results.
[code]
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
"copy",
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
[/code]

I'm so tired of testing. To much options. I loose the depedencies. Do you have a chart
which depedencies i need for a simple tableview with the editor?


And another thing is: How do i create timestamps when i change or create a entry.
I have to DateTime values: datetime_create, datetime_change.

But TableView-Editor can't work with this kind of data-value, right?


Here is my current code:
[code]
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "../dt/extras/Editor/examples/php/birthday.php",
"domTable": "#birthday",
"fields": [
{
"label": "Titel",
"name": "title",
"type": "text"
},
{
"label": "Tag",
"name": "d",
"default": "1",
"type": "text"
},
{
"label": "Monat",
"name": "m",
"default": "1",
"type": "text"
},
{
"label": "Jahr",
"name": "y",
"default": "0",
"type": "text"
}
],
"events": {
"onPreSubmit": function ( o ) {
if ( o.data.title === "test" ) {
this.error('title', 'test is not allowed');
return false;
}
else if ( o.data.title.length >= 20 ) {
this.error('title', 'The browser name length must be less that 10 characters');
return false;
}

// ... etc
}
}
} );

$('#birthday').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "../dt/extras/Editor/examples/php/birthday.php",
"aoColumns": [
{
"mDataProp": "title"
},
{
"mDataProp": "d"
},
{
"mDataProp": "m"
},
{
"mDataProp": "y"
}
],
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
} );
} );
[/code]

Replies

  • allanallan Posts: 63,300Questions: 1Answers: 10,431 Site admin
    First case: You should check the data.action parameter first, and ensure that it is 'edit' or 'create'. When 'delete'ing data it doesn't fill out the full form (no point in validating everything if you are just going to delete it anyway).

    > I can't add any other buttons like "copy". After inserting "copy" i dont get any results.

    Are you getting any errors in Firebug / Inspector at all? Or in your server error log? Possibly a 404 error for the SWF file.

    > How do i create timestamps when i change or create a entry.

    Have you had a look at this example: http://editor.datatables.net/release/DataTables/extras/Editor/examples/dates.html ?

    Allan
This discussion has been closed.