3

I use datagrid Ublaboo\Datagrid on my Nette project. This DataGrid is super, but I have one problem with get ID from component to presenter.

I have show.latte, that get ID to renderShow method in presenter

public function renderShow($id = null) {}

This is OK.

And I have in show.latte table list with datagrid.

   <div class="table-responsive">
       {control fileList}
    </div> 

Presenter:

public function createComponentFileList($name) {
  // return factory method
  return $grid
}

How do I get ID row from show.latte to presenter?

ondrusu
  • 97
  • 4

1 Answers1

1

You can't send information from a view (Latte) to a presenter because presenter methods are executed prior to rendering a view.

What do you need that id for? And which id: renderShow($id = null) seems to know $id already.

You could send information from a component to a presenter in component's method render() via $control->parent / $control->presenter. But again, it's not clear from your question, which id you mean. You don't seem to pass any $id from template to fileList:render() in {control fileList}. Also, at that point, presenter action/render methods have already been executed so I wonder what you'd like to do with that id.

You may have mixed up "presenter" with "component" in your question. You said renderShow() is in a presenter but you ask how to pass id from component to presenter.

"I have show.latte that get ID to renderShow" isn't a grammatically correct sentence. That adds yet another layer of confusion.