addLinkAttribute() public méthode

public addLinkAttribute ( $columnName, $attrName, $attrValue )
Exemple #1
0
    $list->addColumn('publishCol', $I18N->msg('asd_news_publish'), -1, array('<th colspan="4">' . $I18N->msg('actions') . '</th>', '<td>###VALUE###</td>'));
    $list->setColumnFormat('publishCol', 'custom', function ($params) use($list, $clang, $now, $I18N) {
        $publishedAt = new DateTime($list->getValue('publishedAt'));
        if ($list->getValue('publishedAt') == '0000-00-00 00:00:00') {
            return '
            <span class="rex-offline datepicker" data-id="###id###">' . $I18N->msg('asd_news_unpublished') . '</span>
            <span style="height:1px; width:1px; display:block" id="news_###id###" data-clang="' . $clang . '" value="' . $now->format('d/m/Y H:i') . '"></span>';
        }
        $url = $list->getParsedUrl(array('func' => 'unpublish', 'id' => '###id###'));
        return '<a href="' . $url . '" class="rex-online" onclick="return confirm(\'' . $I18N->msg('asd_news_really_unpublish') . '\');">' . $I18N->msg('asd_news_published') . '</a>';
    });
    $list->addColumn('editCol', $I18N->msg('edit'), -1, array('', '<td>###VALUE###</td>'));
    $list->setColumnParams('editCol', array('func' => 'edit', 'id' => '###id###'));
    $list->addColumn('delCol', $I18N->msg('delete'), -1, array('', '<td>###VALUE###</td>'));
    $list->setColumnParams('delCol', array('func' => 'delete', 'id' => '###id###'));
    $list->addLinkAttribute('delCol', 'onclick', 'return confirm(\'' . $I18N->msg('asd_news_really_delete') . '\');');
    $list->addColumn('statusCol', 'offline', -1, array('', '<td>###VALUE###</td>'));
    $list->setColumnFormat('statusCol', 'custom', function ($params) use($list, $I18N) {
        $url = $list->getParsedUrl(array('func' => 'status', 'id' => '###id###'));
        if ($list->getValue('status') == 1) {
            return '<a href="' . $url . '" class="rex-online">' . $I18N->msg('status_online') . '</a>';
        } else {
            return '<a href="' . $url . '" class="rex-offline">' . $I18N->msg('status_offline') . '</a>';
        }
    });
    $list->show();
    echo '
    <script>
    jQuery(document).ready(function($) {

        $(".datepicker").css("cursor", "pointer").click(function() {