How can I search the text in the textbox(input) when DataTable

How can I search the text in the textbox(input) when DataTable

TaiTai Posts: 3Questions: 1Answers: 0
edited February 2019 in Free community support

Dear All
I'm the beginner of this great tool. May I know if possible I can build up a table by DataTable() which can search the text of the textbox(input) in some column(td)?

This question has an accepted answers - jump to answer

Answers

  • TaiTai Posts: 3Questions: 1Answers: 0
    edited February 2019

    The background is
    I'm trying to use the DataTable in one .Net MVC solution.
    When I looping to display the content by a table, some column need to be designed as a TextBox, so that user can input some text and finally click save to sync to DB.
    It looks like
    <tbody>
    <% for (int i = 0; i < Model.Item.SemAttendances.Count; i++)
    { %>
    <tr class="<%:Model.Item.SemAttendances[i].BAA_SALES_CONFIRM == 0 ? "" : "info" %>">
    <!-- First Column for Row# + hidden value -->
    <td>
    <%:Model.Item.SemAttendances[i].ROWNO %>
    <%:Html.HiddenFor(m => m.Item.SemAttendances[i].BAA_BA_ID) %>
    <%:Html.HiddenFor(m => m.Item.SemAttendances[i].BAA_ID) %>
    <%:Html.HiddenFor(m => m.Item.SemAttendances[i].BAA_CSTB_ID) %>
    <%:Html.HiddenFor(m => m.Item.SemAttendances[i].BAA_TYPE) %>
    <%:Html.HiddenFor(m => m.Item.SemAttendances[i].BAA_TYPE_NAME) %>
    <%:Html.HiddenFor(m => m.Item.SemAttendances[i].BAA_ATT_ID) %>
    </td>
    <!-- Second Column for one Type by displayText component -->
    <td style="width: 50px"><%:Html.DisplayTextFor(m => m.Item.SemAttendances[i].BAA_TYPE_NAME) %></td>
    <!-- Third Column for user to input the name -->
    <td style="width: 180px"><%:Html.TextBoxFor(m => m.Item.SemAttendances[i].BAA_ATT_EN_NAME, new { @class="form-control autoname" }) %></td>
    .......

    The situation is I can search the Type because it's a displayText, but can't for Name Textbox.
    The only temp solution I figure out is I can add a hidden or <span style="display:none;"><%:Model.Item.SameText as TextBox%> </span>, so that search can work, but in fact it just search by the span text or hidden value. The search can't support while user actually finish the change for some text. -> It can't search the NEW TEXT, because the page never refresh, and binding the new Text into Model.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @Tai ,

    This example should help - @kthorngren created for an older thread - it shows how to search input elements.

    Cheers,

    Colin

  • TaiTai Posts: 3Questions: 1Answers: 0

    Hi, @colin
    It works for mine, thank you very much.

This discussion has been closed.