@@ -62,48 +62,54 @@ function parseData2(data) {
6262
6363 // Check if it hasn't been registered already to avoid duplicates
6464 if ( $ . fn . dataTable && ! $ . fn . dataTable . ext . search . some ( fn => fn . name === 'refiqdaFilter' ) ) {
65- const refiqdaFilter = function ( settings , data , dataIndex ) {
66- console . log ( 'filtering: ' + dataIndex ) ;
67- var filterTerm = $ ( '#filterby' ) ;
68- if ( settings . nTable . id == filterTerm . val ( ) || filterTerm . val ( ) == 'None' || selectedGUIDs . length === 0 ) {
69- return true ;
65+ const refiqdaFilter = function ( settings , data , dataIndex ) {
66+ console . log ( 'filtering: ' + dataIndex ) ;
67+ var filterTerm = $ ( '#filterby' ) ;
68+ if ( settings . nTable . id == filterTerm . val ( ) || filterTerm . val ( ) == 'None' || selectedGUIDs . length === 0 ) {
69+ return true ;
70+ } else {
71+ console . log ( 'Deciding' ) ;
72+ console . log ( data [ 0 ] ) ;
73+
74+ // Get the actual row from the table using the API
75+ var api = new $ . fn . dataTable . Api ( settings ) ;
76+ var rowNode = api . row ( dataIndex ) . node ( ) ;
77+
78+ if ( ! rowNode ) {
79+ console . log ( 'No row node found for index: ' + dataIndex ) ;
80+ return true ; // If we can't find the node, show it by default
81+ }
82+
83+ var curGuid = $ ( rowNode ) . attr ( 'data-guid' ) ;
84+ var matches = $ ( rowNode ) . attr ( 'data-matches' ) || '' ;
85+
86+ console . log ( 'Examining ' + curGuid + ' with matches: ' + matches ) ;
87+
88+ let found = false ;
89+ selectedGUIDs . forEach ( guid => {
90+ console . log ( "Looking for " + guid ) ;
91+
92+ // If the current row includes a selected guid in its list of related items (forward/child relationships) then show it
93+ if ( matches . includes ( guid ) ) {
94+ console . log ( 'found in matches' ) ;
95+ found = true ;
7096 } else {
71- // get current selections - just keep GUIDs and just look for those GUIDs somewhere
72- console . log ( 'Deciding' ) ;
73- console . log ( data [ 0 ] ) ;
74- //console.log($('.notetable tbody tr:eq('+dataIndex+')').html());
75- let found = false ;
76- selectedGUIDs . forEach ( guid => {
77- console . log ( "Looking for " + guid ) ;
78-
79- var rowNode = settings . aoData [ dataIndex ] ?. nTr ;
80- if ( ! rowNode ) return ;
81-
82- var curGuid = findDataAttribute ( 'data-guid' , rowNode . attributes ) ;
83- console . log ( 'Examining ' + curGuid ) ;
84- // If the current row includes a selected guid in its list of related items (forward/child relationships) then show it
85- let matches = findDataAttribute ( 'data-matches' , rowNode . attributes ) ;
86- console . log ( 'Forward Matching: ' + matches ) ;
87- if ( matches . includes ( guid ) ) {
88- console . log ( 'found' ) ;
89- found = true ;
90- } else {
91- //if the guid for the current row shows up in the list of forward/child relationships for one of the selected items, show it
92- let revMatches = $ ( '[data-guid="' + guid + '"]' ) . attr ( 'data-matches' ) ;
93- if ( typeof revMatches === 'undefined' ) {
94- revMatches = '' ;
95- }
96- console . log ( 'Rev matches: ' + revMatches ) ;
97- console . log ( 'curGUID: ' + curGuid ) ;
98- if ( revMatches . includes ( curGuid ) ) {
99- console . log ( 'rev found' ) ;
100- found = true ;
101- }
102- }
103- } ) ;
104- return found ;
97+ // If the guid for the current row shows up in the list of forward/child relationships for one of the selected items, show it
98+ let revMatches = $ ( '[data-guid="' + guid + '"]' ) . attr ( 'data-matches' ) ;
99+ if ( typeof revMatches === 'undefined' ) {
100+ revMatches = '' ;
101+ }
102+ console . log ( 'Rev matches: ' + revMatches ) ;
103+ console . log ( 'curGUID: ' + curGuid ) ;
104+ if ( revMatches . includes ( curGuid ) ) {
105+ console . log ( 'rev found' ) ;
106+ found = true ;
107+ }
105108 }
106- } ;
109+ } ) ;
110+ return found ;
111+ }
112+ } ;
107113 // Add name property for identification
108114 refiqdaFilter . name = 'refiqdaFilter' ;
109115 $ . fn . dataTable . ext . search . push ( refiqdaFilter ) ;
0 commit comments