protected function countTotalListViewData($keyword = null) {
        $count = 0;

        if ($this->listViewDataClosure != null) {

            if ($this->countListViewDataClosure != null) {
                $c = $this->countListViewDataClosure;
                return  $c($keyword);
            } else {
                return 100000;
            }

        } elseif ($this->searchResultCountClosure != null) {            // For Custom Searching
            $c = $this->searchResultCountClosure;
            return $c($keyword);
            
        } else {
            $this->beforeGetListViewData(function ($tableName, $findClause, $limit, $bindingData) use (&$count) {

                // For RedBean Case
                $count = R::getCell("SELECT COUNT(*) FROM `$tableName` WHERE $findClause $limit", $bindingData);

            }, function ($sql, $limit, $bindingData) use (&$count) {

                // For SQL Case
                $count = R::getRow("SELECT COUNT(*) AS `count` FROM (" . $sql . $limit . ") AS user_defined_query", $bindingData)["count"];

            }, null, null, $keyword);

        }



        return $count;
    }