Selecting a datatable from a list of datatables dynamically

Selecting a datatable from a list of datatables dynamically

vshgeminivshgemini Posts: 2Questions: 0Answers: 0
edited May 2013 in General
Hi,

I've a web page with 3-4 datatables and each datatable has been defined separately inside $(document).ready(). All the data tables have the same ajax source and are populated on page load. Now, I have 4 option buttons with each pointing to one datatable. When an option button is clicked, the corresponding datataable must be populated with data from a new ajax source. How do I select a datatable,clear its contents and load with ajax data from the new ajax source ?

Thanks,
Ray

Replies

  • vshgeminivshgemini Posts: 2Questions: 0Answers: 0
    Below is a sample code :




    Datatable1
    Datatable1
    Datatable1


    $(document).ready(function(){

    //Definition of data tables
    datatable_1 = $('html_table_1').datatable({
    // set attributes, data table fns etc
    // load data from ajaxsource1
    });
    datatable_1 = $('html_table_1').datatable({
    // set attributes, data table fns etc
    });
    datatable_1 = $('html_table_1').datatable({
    // set attributes, data table fns etc
    });

    function fnFireAjaxForRadioButton(optionButtonName) {
    name = "";
    if(name == "datatable1") {
    datatable_1 = null;
    }else if(name == "datatable2") {
    datatable_1 = null;
    }else if(name == "datatable3") {
    datatable_1 = null;
    }
    // all option buttons linked to a common ajax call.
    // fire ajax call . load data from ajaxsource2
    }
    });



    Is the function fnFireAjaxForRadioButton correctly implemented such that the correct data table is chosen and new data loaded in it ?

    Thanks,
    Ray
This discussion has been closed.