From aea70fe721ad5fcee6eef8c96d5da1b513a69553 Mon Sep 17 00:00:00 2001
From: Woraprat <73052317+aeworaprat@users.noreply.github.com>
Date: Wed, 15 Mar 2023 13:11:43 +0700
Subject: [PATCH] update project search

---
 html/exhi/application/views/project/v_project_manage.php  | 8 ++++++--
 .../application/views/project/v_project_manage_user.php   | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/html/exhi/application/views/project/v_project_manage.php b/html/exhi/application/views/project/v_project_manage.php
index 7d2d2ef..9d02aa2 100644
--- a/html/exhi/application/views/project/v_project_manage.php
+++ b/html/exhi/application/views/project/v_project_manage.php
@@ -177,6 +177,10 @@ function create_table(data) {
 	$(".dataTables_length").css('margin-right', '20px');
 	$(".dataTables_info").css('clear', 'none');
 	$(".dataTables_info").css('padding-top', '1');
+	oTable = $('#myTable').DataTable();   //pay attention to capital D, which is mandatory to retrieve "api" datatables' object, as @Lionel said
+	$('#myInput').keyup(function(){
+		oTable.search($(this).val()).draw() ;
+	})
 }
 
 function create_option_year(data){
@@ -195,7 +199,7 @@ function year_filter(){
 	
 	var categoryIndex = 0;
 	$("#myTable th").each(function (i) {
-	if ($($(this)).html() == "Year") {
+	if ($($(this)).html() == "ปี") {
 		categoryIndex = i; return false;
 	}
 	});
@@ -223,7 +227,7 @@ function graduation_filter(){
 	var table = $('#myTable').DataTable();
 	var categoryIndex = 0;
 	$("#myTable th").each(function (i) {
-	if ($($(this)).html() == "Graduation") {
+	if ($($(this)).html() == "ชั้นปี") {
 		categoryIndex = i; return false;
 	}
 	});
diff --git a/html/exhi/application/views/project/v_project_manage_user.php b/html/exhi/application/views/project/v_project_manage_user.php
index c58fc49..44e9fa8 100644
--- a/html/exhi/application/views/project/v_project_manage_user.php
+++ b/html/exhi/application/views/project/v_project_manage_user.php
@@ -176,6 +176,10 @@ function create_table(data) {
 	$(".dataTables_length").css('margin-right', '20px');
 	$(".dataTables_info").css('clear', 'none');
 	$(".dataTables_info").css('padding-top', '1');
+	oTable = $('#myTable').DataTable();   //pay attention to capital D, which is mandatory to retrieve "api" datatables' object, as @Lionel said
+	$('#myInput').keyup(function(){
+		oTable.search($(this).val()).draw() ;
+	})
 }
 
 function create_option_year(data){
@@ -194,7 +198,7 @@ function year_filter(){
 	
 	var categoryIndex = 0;
 	$("#myTable th").each(function (i) {
-	if ($($(this)).html() == "Year") {
+	if ($($(this)).html() == "ปี") {
 		categoryIndex = i; return false;
 	}
 	});
@@ -222,7 +226,7 @@ function graduation_filter(){
 	var table = $('#myTable').DataTable();
 	var categoryIndex = 0;
 	$("#myTable th").each(function (i) {
-	if ($($(this)).html() == "Graduation") {
+	if ($($(this)).html() == "ชั้นปี") {
 		categoryIndex = i; return false;
 	}
 	});
-- 
GitLab