Zend框架的新手,如何将我的php'结果'(巨大的数组)转换成像表一样可行的东西?

时间:2023-02-13 11:21:41
array(556) { ["A1"]=> string(9) "Timestamp" ["B1"]=> string(17) "Untitled Question" ["C1"]=> string(17) "Sample Question 1" ["D4"]=> string(23) "Project Scheduling 2010" ["AJ4"]=> string(4) "2011" ["D5"]=> string(13) "Send Feedback" ["J5"]=> string(4) "JUNE" ["N5"]=> string(3) "JUL"

^ - etc..is the array I'm receiving after successfully connecting to my google spreadsheet and getting a feed for 'all cells'. The problem is that I'm a novice and don't know how to take this array as a data source to convert it into something manageable like gridview/some html table equivalent.

^ - etc ..是我成功连接到谷歌电子表格并获取“所有单元格”的订阅源后收到的数组。问题是我是一个新手并且不知道如何将这个数组作为数据源转换为可管理的东西,比如gridview /某些html表等价物。

What should I do with this array if I basically want to just read it with javascript/css to create a clone that I can work with [by that I mean it looks like a spreadsheet, in the future with some adjustments I'll be able to edit functionality - clicking a cell will open an accordian modal with information from another page etc etc...stuff Google Spreadsheets won't let me code into its interface - I want control here].

如果我基本上只想用javascript / css读取它来创建一个我可以使用的克隆[我的意思是它看起来像一个电子表格,将来我做了一些调整,我应该怎么做这个数组编辑功能 - 单击一个单元格将打开一个手风琴模式,其中包含来自另一个页面的信息等... ... Google Spreadsheets不会让我编码到其界面 - 我想在这里控制]。

If my question is too vague/verbose I'll try to reword it.

如果我的问题太模糊/冗长,我会尝试改写它。

1 个解决方案

#1


0  

class My_View_Helper_GDataTable extends Zend_View_Helper_Abstract
{
    public function gDataTable($data)
    {
        $firstLetter = intval('A');
        $numCols = $this->_getNumCols($data);
        $res = '<table>';
        for ($j = 1; $j <= $numRows; $j++) {
            $res .= '<tr>';
            for ($i = $firstLEtter; $i <= $firstLetter+$numCols; $i++) {
                $res .= '<td>' . $data[$i.$j] . '</td>';
            }
            $res .= '</tr>';
        }
        $res .= '</table>';  
        return $res;          
    }

    protected function _getNumCols($data)
    {
        /*  
            to be implemented
            not sure how exactly can you do it
            zend gdata should offer some method for this
        */
    }
}

Then in view:

然后在视图中:

//somewhere in view init
$view->addHelperPath('some/path', 'My_View_Helper');
//in your view
$this->gDataTable($dataFromZendGdata);

#1


0  

class My_View_Helper_GDataTable extends Zend_View_Helper_Abstract
{
    public function gDataTable($data)
    {
        $firstLetter = intval('A');
        $numCols = $this->_getNumCols($data);
        $res = '<table>';
        for ($j = 1; $j <= $numRows; $j++) {
            $res .= '<tr>';
            for ($i = $firstLEtter; $i <= $firstLetter+$numCols; $i++) {
                $res .= '<td>' . $data[$i.$j] . '</td>';
            }
            $res .= '</tr>';
        }
        $res .= '</table>';  
        return $res;          
    }

    protected function _getNumCols($data)
    {
        /*  
            to be implemented
            not sure how exactly can you do it
            zend gdata should offer some method for this
        */
    }
}

Then in view:

然后在视图中:

//somewhere in view init
$view->addHelperPath('some/path', 'My_View_Helper');
//in your view
$this->gDataTable($dataFromZendGdata);