Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
Source to image : http://tinypic.com/view.php?pic=ev5ma9&s=8#.U1WAufmSxf4

FIND the image here : http://i59.tinypic.com/ev5ma9.jpg[^]

Try this image hosted with different site : http://postimg.org/image/mhdfa4fwx/2e9661ca/[^]

IMAGE CONTENT : Data table with a dropdownlist with 3 list items in my Main view (dropdownlist present on verytop just like sdom toolbar).. Onload Datatable have complete list of data which indirectly be my 1st Listitem .
when 2nd list item selected : Data-table data should change on change of selection in dropdownlist likely same for 3rd list item .

What i need is there is only one ajax source right in my code mentioned below ? so, How to pass my dropdwon selection to AJAXSOURCE ? ?


Well my jquery datatable code :

JavaScript
<script  type="text/javascript">

    $(document).ready(function () {

        var tab = $('#myDataTable').dataTable({
           
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": 'DataProvider',
            "bJQueryUI": true,
            "aoColumns": [
                         {
                             "sName": "ID"
                             , "bVisible" : false
                            
                         },
                         { "sName": "COMPANY_NAME",  "sClass": "hidden-xs" ,
                          "fnRender": function(oObj)
                             {  return '<a href=\"Home/Details/' + oObj.aData[0] + '\">' + oObj.aData[1] + '</a>'; 
                             }
                         },
                         { "sName": "ADDRESS" },
                         { "sName": "TOWN" }
            ]
 
        });
      

        tab.makeEditable({
            "aoColumns": [
 
                null,
                null,
                {
                indicator: 'Saving...',
                tooltip: 'Click to select town',
                loadtext: 'loading...',
                type: 'select',
                onblur: 'submit',
                loadurl: 'AjaxDataProvider1'
        });
    });


</script>

<div class="table-responsive">

<table id="myDataTable" class="table" >
                    <thead >

                         <tr>
                            <th>ID</th>
                            <th >Company name</th>
                            <th>Address</th>
                           <th>Town</th>
                        </tr>
                    
                    </thead>
                        
                    <tbody> 
                       
                   </tbody>

                </table>
    </div>


On top code you can find the ajaxsource there from it i will get data via ajax call . but when i select something in dropdown i am confused how to initially approach .. Any idea is very much Handy .

Any further queries please comment

Regards
Posted
Updated 21-Apr-14 16:14pm
v9
Comments
Guruprasad.K.Basavaraju 21-Apr-14 16:21pm    
Sunil, Confused on whats needed . More info please. Also I cannot access the image so not sure what the issue is.
sunil gutta 21-Apr-14 16:38pm    
i provided u the source image file link . once check it . if u cant access again then say i will upload image here it self
sunil gutta 21-Apr-14 22:04pm    
i hope you are able to access one of those images :) Regards
Guruprasad.K.Basavaraju 21-Apr-14 23:08pm    
Hi sunil, Yes I can see the image now. And I got what you are saying.
This functionality is simple. You need to register a javascript method for onchange event on the dropdown and in the javascript method make an ajax call with the value and bind the datatable again.
sunil gutta 22-Apr-14 14:19pm    
Hi Guru , please check the link :http://www.codeproject.com/Questions/763470/DataTable-Inline-editing-jquery-datatable . Sudden change in functionality i need some quick help else i will lost badly . Ty i will be waiting for your reply badly

1 solution

Here is a very good example..

http://datatables.net/examples/server_side/custom_vars.html

Here is how you should initialise, my data and value will be your drop down value and your ajax method in controller will give the right data back

JavaScript
$(document).ready(function() {
    $('#example').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "../examples_support/server_processing.php",
        "fnServerData": function ( sSource, aoData, fnCallback ) {
            /* Add some extra data to the sender */
            aoData.push( { "name": "more_data", "value": "my_value" } );
            $.getJSON( sSource, aoData, function (json) {
                /* Do whatever additional processing you want on the callback, then tell DataTables */
                fnCallback(json)
            } );
        }
    } );
} );
 
Share this answer
 
Comments
sunil gutta 22-Apr-14 0:33am    
Ok i will look into this and get back to you :) tY Mate
sunil gutta 9-May-14 5:45am    
Thank you mate . i done this using fnserverdata and inside done some magic . regards

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900