jeudi 28 septembre 2017

Wrong checked checkbox Angularjs

I have a problem with a template with AngularJS. The page shows a books list with a checkbox. This is used for batch actions, like delete the books. If the list is too long, the books will be shown in a paged list

The problem is, if I check some of them and change the page number, the checkbox will be checked in the same position. Is easier to understan with this screenshots

Distinct pages and results, same checked checkbox

The get this results I´m using a query in a action.class.php and sending the json like this:

$ejemplares = array();
foreach($data as $ejemplar_bd)
{
    $id_documento = $ejemplar_bd['id_registro'];

    $ejemplar = array();
    $ejemplar['id'] = $ejemplar_bd['id'];
    $ejemplar['idDoc'] = (int)$ejemplar_bd['id_registro'];
    $ejemplar['numregistro'] = (int)$ejemplar_bd['numregistro'];
    $ejemplar['codigo'] = $ejemplar_bd['codigoejemplar'];
    $ejemplar['estado'] = $ejemplar_bd['estado'];
    $ejemplar['signatura'] = $ejemplar_bd['signatura1']."-".$ejemplar_bd['signatura2']."-".$ejemplar_bd['signatura3'];
    $ejemplar['tipo'] =$ejemplar_bd['tipoejemplar'];
    $ejemplar['reservas']=$ejemplar_bd['reservas'];
    $ejemplar['Ubicacion']=$ubicaciones[$ejemplar_bd['id']];
    $ejemplar['Motivo']=$ejemplar_bd['motivo_expurgado'];
    $ejemplar['Editorial']=$data_editorial['valor'];
    $ejemplar['Imprimido']= $ejemplar_bd['imprimido'];
    $ejemplar = array_merge($ejemplar,$fondos[$id_documento][$ejemplar['id']]);

    $ejemplares[] = $ejemplar;

}

$this->json_data = json_encode($ejemplares);

After that, the code in the template is:

<tr ng-repeat="item in data| filter:Buscar | filtroNumregistro:numregistro | filtroCodEjemplar:codEjemplar | filtroNombreNormalizado:nombreFiltro  | orderBy:sort:reverse | limitTo: (currentPage - 1) * pageSize - filtrados.length | limitTo: pageSize track by $index">
        <td class="sf_admin_text sf_admin_list_td_nombre">
          <input type="checkbox" name="ids[]" value="" class="sf_admin_batch_checkbox">
        </td>
        <td class="sf_admin_text">
          
        </td>
        <td class="sf_admin_text">
          
        </td>
        <td class="sf_admin_text sf_admin_list_td_titulo">
            <span><a ng-href=""></a></span><br/>
            <span class="autorListEjemplar" ng-repeat="autor in item.Autor"></span>
        </td>
        <td class="sf_admin_text" style="width:10%;">
          
        </td>
        <td class="sf_admin_text" style="width:10%;">
          
        </td>
        <td class="sf_admin_text" style="width:10%;">
          
        </td>
        <td class="sf_admin_text" style="width:10%;">
          
        </td>
        <td class="sf_admin_text">
          
        </td>
      </tr> etc...

What is going on? What could be the problem?

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire