I have created search panel like following example (like forum-search example)

    var ds = new Ext.data.Store({
        url: 'search.php',
        reader: new Ext.data.JsonReader({
           root: 'topics',
           totalProperty: 'totalCount',
           id: 'post_id'
         {name: 'postId', mapping: 'post_id'},
        {name: 'title', mapping: 'topic_title'},
         {name: 'topicId', mapping: 'topic_id'},
        {name: 'author', mapping: 'author'},
         {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
         {name: 'excerpt', mapping: 'post_text'}

       , autoLoad: false

    var resultTpl = new Ext.XTemplate(
        '<tpl for=".">',
        '<div class="search-item">',
            '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>',
            '<a href="http://extjs.com/forum/showthread.php?t={topicId}&p={postId}" target="_blank">{title}</a></h3>',

        var panel = new Ext.Panel({
        applyTo: 'search',
        title:'Forum Search',

        items: new Ext.DataView({
            tpl: resultTpl,
            store: ds,
            loadingText : 'Searching...',
            itemSelector: 'div.search-item'

        tbar: [
            'Search: ', ' ',
            new Ext.ux.form.SearchField({
                store: ds,


Search consists of tbar (from SearchField.js) and Data view. See following attached image


The json data can be {\"totalCount\":5,\"topics\":[....]} or {\"totalCount\":0,\"topics\":[]}

If totalCount is 0, "No result to display" should be shown, otherwise data should be shown.

Can I implement dynamic Ext.XTemplate for this data view.

Besides, when I click x button in tbar, all data in dataview should be removed and "No result to display" should not be shown (No data is shown in data view). So, I don't assign any value in emptyText of data view.

Anyone have any idea?

Thank in advance.