Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDeleteRow only getting element names, not data #190

Open
JoeBlackSecurity opened this issue Sep 12, 2021 · 0 comments
Open

onDeleteRow only getting element names, not data #190

JoeBlackSecurity opened this issue Sep 12, 2021 · 0 comments

Comments

@JoeBlackSecurity
Copy link

Let me start by saying I don't know JavaScript very well. So I am going at this the best I can.

When calling onDeleteRow, all of the fields would return undefined. The callback provides valid element names but not data.

The problem lies here somewhere around row 574:

// Getting the IDs and Values of the tablerow
for (var i = 0; i < dt.context[0].aoColumns.length; i++) {
    // .data is the attribute name, if any; .idx is the column index, so it should always exists
    var name = dt.context[0].aoColumns[i].data ? dt.context[0].aoColumns[i].data :
            dt.context[0].aoColumns[i].mData ? dt.context[0].aoColumns[i].mData :
            dt.context[0].aoColumns[i].idx;
    jsonDataArray[name] = adata.data()[0][name];
}

that.onDeleteRow(that,
    jsonDataArray,
    function(data){ that._deleteRowCallback(data); },
    function(data){ that._errorCallback(data); }
);

I can see that the data is never pushed into jsonDataArray.
I got around this by changing

that.onDeleteRow(that,
  jsonDataArray,

to

that.onDeleteRow(that,
adata.data()[0]

adata.data()[0] was at least mostly the right data that should be returned so I can use it in the onDeleteRow function.

Perhaps someone smarter than me can work out why the loop isnt working correctly?
For reference, add and edit work just fine. The delete model loads with all the correct data, its only submitting delete that I was having trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant