set values for idSrc

set values for idSrc

vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
edited April 2013 in Editor
Hi Allan,
I used to set value for idSrc while initialing the editor
[code]
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": {..... },
"domTable": "#example",
"idSrc": "myId",
"fields": .....
[/code]

In my project i need to assign idSrc after initialisation which will be depending on some browser events. Can I use this new values to update idSrc already set? If no any other method ?
Tried the following code but didnt work.
[code]
editor.on( 'onInitEdit', function (e) {e.idSrc=myNewId;} );
[/code]
Please suggest a way to get out of it
Regards
vinod

Replies

  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    Hi,
    Regarding the above post, Is it possible to initialize the editor instance again, just before the editor form open up.
    Or can i use events on editor to manipulate the idSrc or DT row id value to be submited to the editor.
    What ever method I use my aim is to send custom id along with action , table and data
    Hope Allan can help me on it.
  • allanallan Posts: 61,683Questions: 1Answers: 10,100 Site admin
    > Is it possible to initialize the editor instance again, just before the editor form open up.

    No - that would be a different Editor instance. You can have as many instances as you want, but they are independent - one cannot control another.

    You might be able to do it by setting the private properties, but cannot you not just initialise Editor once you know what the value should be?

    Allan
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    Allan, thanks for the reply
    Since my intention is to change the idSrc according the clicks made inside the table columns, I cant initialize the editor after knowing the value(else, each click may cause new initialization). So I have to search another method to replace in the idSrc value already set in the initialization.
    If there is no possibility for that, I am planning to change the row id temporally- on click so that i can submit my server the exact id I want (it works ,but the return Json I have to manipulate again accordingly..bit of complication)
    Any way, thank you for this plugin for its numerous possibilities.
    Regards
    Vinod
  • allanallan Posts: 61,683Questions: 1Answers: 10,100 Site admin
    > I cant initialize the editor after knowing the value(else, each click may cause new initialisation)

    I'm not sure I see the problem with that?

    However, you might want to look at using editor.s.idSrc ( http://editor.datatables.net/docs/current/Editor.models.settings.html#idSrc ). It's a 'private' property (although accessible), so it is possible it might change between versions, but you could write your change in idSrc to that and that would work. However, as I say, this is not a support public API, so it might change in future.

    Allan
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    Thank you Allan,
    You are right, multiple initialization did n't make any problem ,it was tested and just taking the latest config settings. Hence I dropped the plan of accessing the s.idSrc and re-config it ( I may forget about it when new version comes :))
    Thank you once again for your excellent support.
    Vinod
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    edited April 2013
    Allan,
    One more doubt about refreshing/reloading the table with newly added data. On successful completion of a create operation a custom Jason was made to replace the existing one. As this row is already available in the table, it does not update or add to the table as new raw ( Worth to note that, after successful edit operation it works well for me, as the returned data is replacing the existing row in the table. )

    So, what I m looking for a solution that treat successful create json row similar to that of json processing that of edit data.

    If not possible, Is there any provision to reload the data table on successful completion of create operation. Or call get operation soon after the completion of create operation.

    Thanking you
    Vinod
This discussion has been closed.