Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82109

Row ID after Editor Update

$
0
0
Not sure if this question should go in the General Forum, or here in the Editor Forum.

I have a dataTable configured using Editor and everything works PERFECTLY. Love this solution. Here's my problem I'm trying to figure out.

When I Create or Update a record using Editor, everything works except for the following scenario:

On certain pages, I have created an addition external link besides Update and Delete. This link takes you to another page that updates a list of values for the record you were just on. To explain it better, I have a table that is a list of defined Metrics. You can update or delete each Metric using links I've placed in a column of the table:

                    {
                        'mData': null,
                        'bSortable': false,
                        'sClass': 'center nowrap',
                        'sDefaultContent': '<a href="" class="tip-top editor_edit" data-original-title="Update"><i class="icon-ok"></i></a>&nbsp;<a href="" class="tip-top editor_remove" data-original-title="Delete"><i class="icon-remove"></i></a>&nbsp;<a href="" class="tip-top editor_values" data-original-title="Values"><i class="icon-list-alt"></i></a>'
                    }

Notice the last link named "Values". This calls a function I've created:

            // Values
            $('.datatable').on('click', 'a.editor_values', function (e) {
                e.preventDefault();

                var row = $(this).closest('tr'),
                data = oTable._(row),
                id = data[0].id;

                window.location = '/Metrics/Metric-Values/' + id;
            });

This links to another page, passing the id of the row as a parameter to make sure we load values for that particular record. Each Metric record can have unlimited Values associated with it.


Now here's the problem. When I load the Metrics page, clicking on that Value link works absolutely fine...it passes the proper row id. However, if I create a New record or Update an existing record, somehow that row id is no longer available and I end up with "undefined" as the parameter when I click on Values and redirect.

All of my JSON results contain an id value and a row[DT_RowId] value when doing creates and updates, and if I inspect the DOM AFTER doing an update, I can still see the correct id attached to the row. It's just somehow not accessible in my a.editor_values function anymore.

I know that was pretty complicated to explain, but if you have any possible suggestions on a way to remedy this situation, I'd appreciate them. It's not a huge deal to ask people to refresh the page, but I'd rather not have to.

Thanks so much!

Viewing all articles
Browse latest Browse all 82109

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>