How do I grab the value of a jquery datepicker within a de-selected row

How do I grab the value of a jquery datepicker within a de-selected row

c-myers1c-myers1 Posts: 43Questions: 16Answers: 0

It's the 2nd day I've been stuck trying different permutations of this. When a row is de-selected, I need a certain 'fixdate' field blanked out within that row.

Looking at the first example at https://datatables.net/reference/event/deselect, I have:

// dtbl hitherto initialized with the table jquery object

dtbl.row().on( 'deselect', function ( e, dt, type, indexes ) {
       if ( type === 'row' ) {
        var data = dtbl.rows( indexes ).data().pluck('fixdate').data("kendoDatePicker").value('');
       }
});

Nothing I've tried has worked.

Replies

  • kthorngrenkthorngren Posts: 21,300Questions: 26Answers: 4,945

    If you are dealing with just one row then you will want to use row() instead of the plural rows().

    dtbl.row( indexes ).data()

    This would be used as both the getter then the setter. You would do something like this:

    dtbl.row().on( 'deselect', function ( e, dt, type, indexes ) {
           if ( type === 'row' ) {
            var data = dtbl.rows( indexes ).data();  //get the data for the row
            data.kendoDatePicker = '';  //set the value to blank
            dtbl.rows( indexes ).data( data )  //place the updated data back into the row
           }
    });
    

    You can see an example of this here:
    http://live.datatables.net/kahuwali/1/edit

    Kevin

  • c-myers1c-myers1 Posts: 43Questions: 16Answers: 0

    Thanks but for my case, this would blank out the markup for the kendo date picker. I want to change only it's value not blank out the element itself. So how can this be done?

  • c-myers1c-myers1 Posts: 43Questions: 16Answers: 0
    edited April 2018

    Well my final working permutation is
    var idx = dtbl.row( indexes ).id(); var res = data.replace("row", "datepicker"); $("[idx="+res+"]").data("kendoDatePicker").value('');

This discussion has been closed.