public function fetchDataSet()
    {
        $dataObj = $this->getDataObj();

        if (!$dataObj) {
            return null;
        }

        if ($this->isRefreshData) {
            $dataObj->resetRules();
        } else {
            $dataObj->clearSearchRule();
        }

        if ($this->fixSearchRule) {
            if ($this->searchRule) {
                $searchRule = $this->searchRule . " AND " . $this->fixSearchRule;
            } else {
                $searchRule = $this->fixSearchRule;
            }
        } else {
            $searchRule = $this->searchRule;
        }

        $dataObj->setQueryParameters($this->queryParams);
        $dataObj->setSearchRule($searchRule);
        if ($this->startItem > 1) {
            $dataObj->setLimit($this->range, $this->startItem);
        } else {
            $dataObj->setLimit($this->range, ($this->currentPage - 1) * $this->range);
        }
        if ($this->sortRule && $this->sortRule != $this->getDataObj()->sortRule) {
            $dataObj->setSortRule($this->sortRule);
        }
        $resultRecords = $dataObj->fetch();
        $this->totalRecords = $dataObj->count();
        if ($this->range && $this->range > 0) {
            $this->totalPages = ceil($this->totalRecords / $this->range);
        }
        $selectedIndex = 0;

        //if current page is large than total pages ,then reset current page to last page
        if ($this->currentPage > $this->totalPages && $this->totalPages > 0) {
            $this->currentPage = $this->totalPages;
            $dataObj->setLimit($this->range, ($this->currentPage - 1) * $this->range);
            $resultRecords = $dataObj->fetch();
        }

        $this->getDataObj()->setActiveRecord($resultRecords[$selectedIndex]);

        if (!$this->recordId) {
            $this->recordId = $resultRecords[0]["Id"];
        } else {
            $foundRecordId = false;
            foreach ($resultRecords as $record) {
                if ($this->recordId == $record['Id']) {
                    $foundRecordId = true;
                }
            }
            if ($foundRecordId == false) {
                $this->recordId = $result[0]['Id'];
            }
        }

        return $resultRecords;
    }