简体   繁体   中英

jQuery Template Ignores String.Empty Values

I have an ASP .Net Webservice which returns a System.Data.DataTable like object (contains rows and columns, with the cell values being strings) which is serialised to JSON.

I want use this data table JSON result to populate an HTML table using jQuery Template.

If a row contains an empty cell ( String.Empty ) I still want it to print <td></td> else my table structure will get messed up. jQuery template seems to be treating String.Empty as null and skipping it rather than including an empty table cell.

Example of my JSON row

{"ItemArray":["Job 1 Status","Completed","","Active","Failed","Completed"]}]}

Example of my templates

<script id="tableRowTemplate" type="text/x-jquery-tmpl">
    <tr>{{tmpl(ItemArray) "#tableRowCellTemplate"}}</tr>
</script>
<script id="tableRowCellTemplate" type="text/x-jquery-tmpl">
        <td>${}</td>
</script>

I am using jQuery 1.6.4 and jQuery template 1.0.0pre. I could quite easily replace String.Empty with a pending status and then check for this in my template, but I would rather not do a workaround.

Update: The jQuery template project has been abandoned in its current form.

This question seems to have become active again—unlike this jQuery template project.

The jQuery template project is dead and never made it out of beta, so the answer is that there is no solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM