How do i set custom filter my datatable when i click on a selected record ?

Hi ,
i have 2 json data , master and detail ,

where both i have defined for them datatable each and when i select a record in
the master datatable , how do i assign the selected field value ,i.e. do_id and set a filter for my detail datatable , i have a button “show_detail” in my header of my master datatable view , and i set the onclick event for the button with code detail.filter() ,

$$("my_detail_linelist").filter( function(obj){
    return (obj.do_id  == $$$("masterlist").elements["do_id"].getValue() ) ;
}) ;

i have tried both the template and function of the datatable(grid) filter , it has not effect , can anyone show me what i did wrong or what is the proper way of achieving this ?

thanks,

FYI , i have tried the header filter , which i need to manually type in my do_id to activate the filter and it works .

Try this (in the onClick handler of your button):

var sel =  $$("masterlist").getSelectedId();
if(sel){
   $$("my_detail_linelist").filter( function(obj){
     return obj.do_id  ==  sel.row;
   }) ;
}

where sel.row is the ID of the selected row in the master datatable.