SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    model view question

    I hav an MVC app...

    I have a controller that gets a command from the _GET array, then creates a object to handle that command. command object then creates and returns a view object. very basic...

    I have a datagrid object that creates and populates a table with values, it has a render method that I call to output the table in html.

    now I create this datagrid and define the data in my command object, then pass it to my view class to be rendered.

    Is this correct, or should I be creating the datagrid in my view class

    thnx,

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would need to see some script to give a real answer for you but if there is any kind of structural markup used for the datagrid within the Controller then this'd need to be put to the View.

    Could you post the script your using at the moment? I have no idea of how your passing the model data to the View either

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    command class
    PHP Code:
        class MailingListTable extends BaseCommand
        
    {
            function 
    MailingListTable()
            {
                
    parent::BaseCommand();

                
    // create recordset
                
    $do = new DataObject_db_mysql$g_conn );
                
    $do->openTable'mailinglist' );  // open mysql table
                
    $do->Sort'email' );  // sort recordset by email
                
    $do->Filter'active' '='true );   // remove records where active is false

                /* create datagrid and pass recordset to datagrid, then set grid properties that determine how the grid will display and function once rendered */
                
    $grid = new HtmlControl_DataGrid'DataGrid' );
                
    $grid->attachDataSource$do );

                
    $grid->CanUpdate=true;  
                
    $grid->CanAppend=true;
                
    $grid->CanDelete=true;
                
    $grid->ShowPrimaryKey=true;
                
    $grid->DisplayRows=10;  // rows to display page

                // create view and pass datagrid to view
                
    $this->_view = new TableView$grid );
                
    // set template file
                
    $this->_view->getTemplate'/templates/mailinglist.tpl' );
            }
        } 
    view class
    PHP Code:
        class TableView extends BaseView
        
    {
            var 
    $_ctrl;

            function 
    TableView$ctrl )
            {
                
    parent::BaseView();
                
    $this->_ctrl $ctrl;
            }

            function 
    view()
            {
                
    /* note there are some methods in the base class not shown, the view method is invoked by another method that parses the template, then adds the content below */

                
    $this->_ctrl->Render();  // echos the html table
            
    }
        } 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •