Symfony2实现输入文本并重新加载元素列表

I'm new to symfony2 and I need a few of guide for to implmement one thing.

I have an input text, and a table with data from database.

I desire that when the user type text into the input text, the table is reload with the new data from the database.

Function I desire to call from the controller:

public function reloadCountryAction($name){
    $em = $this->getDoctrine()->getEntityManager();
    $qb = $em->createQueryBuilder();
    $qb->select("*")
        ->from("COUNTRY","p")
        ->where("p.COUNTRYNAME like '%:identifier%'")
        ->setParameter('identifier', $name);
    return $qb->getArrayResult();
}

Input text where the user will type the item to search:

<input type="search" id="searchCountry" >

The function that feed the table for first time:

public function countryListAction() {
    $usr = $this->get('security.context')->getToken()->getUser();

    $allCountry = $this->getDoctrine()
            ->getRepository('backendentityBundle:Country')
            ->findAll();

    return $this->render('backendcountryBundle:Default:countryFirst.html.twig', array('sessionname' => $usr->getUsername(),
                'allCountry' => $allCountry));
}

and the table that I want to reload:

<table id="selectableTableCountry">
    {% for country in allCountry %}
        <tr id="rowtable" class="ui-widget-content">
            <td>
                <p class="txtCountryName">{{ country.countryname}}</p>
            </td>
        </tr>
    {% endfor %}
</table>

Thanks

it s javascript problem, not symfony. You should use ajax call for reload datas from your database, or just post it when unfocus is triggered on your element.

It's not a question about symfony, but javascript I think. You should listen (onkeyup in ex.) on input #searchCountry and perform ajax to route which calls reloadCountryAction and renders new table <table id="selectableTableCountry">...</table>. Just change it in current DOM.