0 Пользователей и 1 Гость просматривают эту тему.
  • 5 Ответов
  • 1090 Просмотров
*

artem9515

  • Новичок
  • 7
  • 0 / 0
Доброго времени суток. Надеюсь добрые люди помогут.
Дело такое : Есть БД, таблицей вывожу ее в фронтенд. Таблица сортируется и есть фильтр с помощью DataTables. Все организовано с помощью компонента. Один из столбцов статус выполнения.
Вопрос: Как можно сделать редактирование строк этого столбца? Первая мысль - JToolBarHelper, но он разрешен только в бекенде.

Если есть хотя бы какие-то мысли или предложения пишите! За раннее спасибо.
« Последнее редактирование: 29.08.2015, 01:57:58 от artem9515 »
*

b2z

  • Глобальный модератор
  • 7290
  • 778 / 0
  • Разраблю понемногу
Сделать отдельное представление для редактирования записи и там редактировать столбец. Либо сделать AJAX редактирование, что конено круче и удобней, но немного сложней в исполнении.
*

AlekVolsk

  • Гуру
  • 6915
  • 415 / 4
Покажите пример, как это у вас реализовано, или ссылку на страницу с реализацией, а лучше и то и другое.
*

robert

  • Живу я здесь
  • 4974
  • 457 / 20
Вроде ничего сверхестественного нет:
- В фронтальном контроллере создать метод, который загружает модель из админки (нет нужды плодить дублирующий код, ведь в админке вы как-то сохраняете данные, верно?) и вызывает метод модель->save().
- Поместить редактируемое поле в форму, а на форму повесить скриптик, который AJAX'ом отправляет данные на контроллер.
Не будь паразитом, сделай что-нибудь самостоятельно!
*

artem9515

  • Новичок
  • 7
  • 0 / 0
Вот так! Чек бокс для отметки что статус надо поменять на "1"


Код
<?php
/** @var $this ZapisyViewForm_For_Administr */
defined( '_JEXEC' ) or die; // No direct access


?>
<script src="/joomla/media/jui/js/jquery.js"></script>
<script src="/joomla/media/jui/js/jquery.min.js"></script>
<script src="/joomla/media/jui/js/jquery.tablesorter.js"></script>
<script src="/joomla/media/jui/js/jquery.tablesorter.widgets.js"></script>


<!-- Bootstrap stylesheet -->
<link rel="stylesheet" href="/joomla/media/jui/docs/css/bootstrap.min.css">

<!-- bootstrap widget theme -->
<link rel="stylesheet" href="/joomla/media/jui/css/theme.bootstrap.css">

<link rel="stylesheet" href="/joomla/media/jui/addons/pager/jquery.tablesorter.pager.css">
<script src="/joomla/media/jui/addons/pager/jquery.tablesorter.pager.js"></script>



<script id="js">
$(function() {

  // NOTE: $.tablesorter.theme.bootstrap is ALREADY INCLUDED in the jquery.tablesorter.widgets.js
  // file; it is included here to show how you can modify the default classes
  $.tablesorter.themes.bootstrap = {
    // these classes are added to the table. To see other table classes available,
    // look here: http://getbootstrap.com/css/#tables
    table        : 'table table-bordered table-striped',
    caption      : 'caption',
    // header class names
    header       : 'bootstrap-header', // give the header a gradient background (theme.bootstrap_2.css)
    sortNone     : '',
    sortAsc      : '',
    sortDesc     : '',
    active       : '', // applied when column is sorted
    hover        : '', // custom CSS required - a defined bootstrap style may not override other classes
    // icon class names
    icons        : '', // add "icon-white" to make them white; this icon class is added to the <i> in the header
    iconSortNone : 'bootstrap-icon-unsorted', // class name added to icon when column is not sorted
    iconSortAsc  : 'glyphicon glyphicon-chevron-up', // class name added to icon when column has ascending sort
    iconSortDesc : 'glyphicon glyphicon-chevron-down', // class name added to icon when column has descending sort
    filterRow    : '', // filter row class; use widgetOptions.filter_cssFilter for the input/select element
    footerRow    : '',
    footerCells  : '',
    even         : '', // even row zebra striping
    odd          : ''  // odd row zebra striping
  };

  // call the tablesorter plugin and apply the uitheme widget
  $("table").tablesorter({
    // this will apply the bootstrap theme if "uitheme" widget is included
    // the widgetOptions.uitheme is no longer required to be set
    theme : "bootstrap",

    widthFixed: true,

    headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!

    // widget code contained in the jquery.tablesorter.widgets.js file
    // use the zebra stripe widget if you plan on hiding any rows (filter widget)
    widgets : [ "uitheme", "filter", "zebra" ],

    widgetOptions : {
      // using the default zebra striping class name, so it actually isn't included in the theme variable above
      // this is ONLY needed for bootstrap theming if you are using the filter widget, because rows are hidden
      zebra : ["even", "odd"],

      // reset filters button
      filter_reset : ".reset",

      // extra CSS class name (string or array) added to the filter element (input or select)
      filter_cssFilter: "form-control",

      // set the uitheme widget to use the bootstrap theme class names
      // this is no longer required, if theme is set
      // ,uitheme : "bootstrap"

    }
  })
  .tablesorterPager({

    // target the pager markup - see the HTML block below
    container: $(".ts-pager"),

    // target the pager page select dropdown - choose a page
    cssGoto  : ".pagenum",

    // remove rows from the table to speed up the sort of large tables.
    // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
    removeRows: false,

    // output string - default is '{page}/{totalPages}';
    // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
    output: '{startRow} - {endRow} / {filteredRows} ({totalRows})'

  });

});
</script>



<form action="<?php echo JRoute::_( 'index.php?view=Form_For_Administr' )?>" method="post" class="form-validate">
<table class="table table-striped table-bordered table-condensed">
     <thead>
       <tr>
            <th></th>
           <th>ФИО</th>
           <th>Создано</th>
           <th>Ном.Полиса</th>
           <th>Телефон</th>
           <th>Ст</th>
       </tr>
     <thead>
     <tfoot>
       <tr>
        <th></th>
        <th>ФИО</th>
        <th>Создано</th>
        <th>Ном.Полиса</th>
        <th>Телефон</th>
        <th>Ст</th>
        </tr>
        <tr>
         <th colspan="6" class="ts-pager form-horizontal">
                <button type="button" class="btn first"><i class="icon-step-backward glyphicon glyphicon-step-backward"></i></button>
                <button type="button" class="btn prev"><i class="icon-arrow-left glyphicon glyphicon-backward"></i></button>
                <span class="pagedisplay"></span> <!-- this can be any element, including an input -->
                <button type="button" class="btn next"><i class="icon-arrow-right glyphicon glyphicon-forward"></i></button>
                <button type="button" class="btn last"><i class="icon-step-forward glyphicon glyphicon-step-forward"></i></button>
                <select class="pagesize input-mini" title="Select page size">
                  <option selected="selected" value="10">10</option>
                  <option value="20">20</option>
                  <option value="30">30</option>
                  <option value="40">40</option>
                </select>
                <select class="pagenum input-mini" title="Select page number"></select>
              </th>
        </tr>
      </tfoot>
        <tbody>
         <?php if ($this->rows): foreach ($this->rows as $i => $row):
          $checked = JHTML::_('grid.id', $i, $row->id);
          $link = 'index.php?option=com_zapisy&view=create' . $row->id;
         ?>
     <tr class="row<?php echo $i ; ?>">
         <td><?php echo $checked; ?></td>
         <td><?php echo $row->fio; ?></td>
         <td><?php echo $row->created; ?></td>
         <td><?php echo $row->nom_polis; ?></td>
         <td><?php echo $row->cont_tel; ?></td>
         <td><?php echo $row->status; ?></td>
     </tr>
     <?php  endforeach;  else: ?>
     <tr>
         <td colspan="15">Пациентов нет</td>
     <tr>
     <?php endif; ?>
    </tbody>
</table>
<input type='hidden' name='status'       value = '1' />
<input type="hidden" name="task" value="Form_For_Administr.save" />
    <input type="submit" value="Отправить" />
</form>




« Последнее редактирование: 18.10.2015, 18:13:11 от artem9515 »
*

artem9515

  • Новичок
  • 7
  • 0 / 0
Вроде ничего сверхестественного нет:
- В фронтальном контроллере создать метод, который загружает модель из админки (нет нужды плодить дублирующий код, ведь в админке вы как-то сохраняете данные, верно?) и вызывает метод модель->save().
- Поместить редактируемое поле в форму, а на форму повесить скриптик, который AJAX'ом отправляет данные на контроллер.
Как скрипт повесить?
Как я в таблицу значение формы запихну?
« Последнее редактирование: 18.10.2015, 19:57:43 от artem9515 »
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Checkbox с заваписью в БД во фронтенде

Автор sashaiv

Ответов: 6
Просмотров: 798
Последний ответ 19.05.2018, 21:43:27
от sashaiv
Запрос в базу

Автор User82

Ответов: 5
Просмотров: 745
Последний ответ 28.10.2017, 12:29:03
от fsv