This is a migrated thread and some comments may be shown as answers.

Autocomplete cannot get working with XML file

1 Answer 140 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 24 Feb 2012, 03:32 PM
HI,
I am playing around with Kendo UI Widgets and am hoping to get them working with my API but cannot find any examples using XML, most use JSON OR ODATA and so I am therefore struggling to get the below working after trying many different variations. Am I missing something?  Can The datasource be XML?

 I hope when I get this working all other widgets etc will be easy for me to suss out.  Can anyone help get me started?

<div class="search">
        <input id="autoComplete" name="txtQuickSearch" type="text" value="product search" onclick="this.value='';" onblur="if(this.value=='')this.value='product search';" class="search_field" />
    </form>
</div>
<script>
$(document).ready(function() {
    $("#autoComplete").kendoAutoComplete({
         minLength: 3,
         dataTextField: "productName", // XML property name to use
         dataSource: new kendo.data.DataSource({
         type: "xml", // specifies data protocol
        pageSize: 10, // limits result set
       // data: "/products/product/productName",
 transport: {
 },
  schema: {
      type: "xml",
      data: "/products/product",
      model: {
          fields: {
              productName: "productName"
          }
      }
  }     
})
              //below doesnt work
            /*  minLength: 3,
              //dataTextField: "ProductName",
              separator: ", ",
              dataSource: {
                  type: "xml",
                  serverFiltering: true,
                  serverPaging: true,
                  pageSize: 20,
                  
                  transport: {
                      read: "products.xml"
                  }
              }*/
          });
      });

1 Answer, 1 is accepted

Sort by
0
Lee
Top achievements
Rank 1
answered on 24 Feb 2012, 05:00 PM
Ive solved it,see the below.
    $("#autoComplete").kendoAutoComplete({
        minLength: 3,
        dataTextField: "productName", // XML property name to use
        dataSource: new kendo.data.DataSource({
         type: "xml", // specifies data protocol
         pageSize: 10, // limits result set
         transport: {
          read: "products.xml"
         },
          schema: {
              type: "xml",
              data: "/products/product",
              model: {
                  fields: {
                      productName: "productName/text()"
                  }
              }
          }      
        })
    });
});
Tags
AutoComplete
Asked by
Lee
Top achievements
Rank 1
Answers by
Lee
Top achievements
Rank 1
Share this question
or