Change the action of the create or edit button in the editor

Change the action of the create or edit button in the editor

DiegoTcDiegoTc Posts: 10Questions: 0Answers: 0
edited June 2013 in Editor
Hi
I have my data table fill with information and will use the editor for adding and editing rows.
I have a great doubt, I want to change the actions of the buttons, for example when I click in create, I don't want to create a new row I just want an alert that says you will create a new record in the future.
How do I do this?
I am asking this, because I will need to create the events for adding and editing because I am using jsp no php. So I need to understand how does the editor works. Thanks in advance.
[code]
var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
"bProcessing": true,
"sAjaxSource": 'tomacorrienteslist.jsp',
"domTable": "#example",
"fields": [ {
"label": "Codigo",
"name": "codigo"
}, {
"label": "Descripcion",
"name": "descripcion"
}, {
"label": "XBee",
"name": "xbee_id"
}
]
} );

$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": 'tomacorrienteslist.jsp',
"sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",

"aoColumns": [
{ "mData": "codigo" },
{ "mData": "descripcion" },
{ "mData": "xbee_id" }
],
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
} );
} );

[/code]

Replies

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    You'd be better off just defining a new TableTool button, rather than modifying the Editor buttons. Something like:

    [code]
    {
    sExtends: "text",
    fnClick: function ( button, config ) {
    alert( 'Wotcha!' );
    }
    }
    [/code]

    Allan
  • DiegoTcDiegoTc Posts: 10Questions: 0Answers: 0
    But what about the editing window?
    I still want it. (It looks cool)
  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    I don't really understand? You mentioned changing the create button - if you want editing to stay as it is, just leave the edit button in place.

    Allan
  • DiegoTcDiegoTc Posts: 10Questions: 0Answers: 0
    I refer to this
    instead of calling the alert(Hello)

    [code]
    function showDialog()
    {
    $("#dialog-modal").dialog(
    {
    width: 600,
    height: 400,
    open: function(event, ui)
    {
    var textarea = $('');
    $(textarea).redactor({
    focus: true,
    autoresize: false,
    initCallback: function()
    {
    this.set('Lorem...');
    }
    });
    }
    });
    }

    [/code]

    I want to call the showDialog(),

    It will be this way

    [code]
    {
    sExtends: "text",
    fnClick: function ( button, config ) {
    showDialog();
    }
    }
    [/code]
  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    That looks fine to me. What about it doesn't work?

    Allan
  • DiegoTcDiegoTc Posts: 10Questions: 0Answers: 0
    edited June 2013
    It doesn't shows anything.
    No dialog is show. I am wondering which is the problem :(
This discussion has been closed.