[CLOSED] ComboBox with Templates and AJAX

  1. #1

    [CLOSED] ComboBox with Templates and AJAX

    I try to implement Combobox with Proxy but it doesn't display any data.

    == ASPX Page
         <ext:ComboBox ID="CombPrimeVendors" 
            runat="server" 
            DisplayField="LGL_NM" 
            ValueField="LGL_NM"
            TypeAhead="false"
            Width="570"
            PageSize="10"
            HideBaseTrigger="true"
            MinChars="0"
            TriggerAction="Query" >
            <ListConfig  LoadingText="Searching...">
                <ItemTpl ID="ItemTpl1" runat="server">
                    <Html>
                        <div class="search-item">
                            <h3><span>{VEND_CUST_CD}</span>{LGL_NM}</h3>
                            {ccVendorID}
                        </div>
                    </Html>
                </ItemTpl>
            </ListConfig>
            <Store>
                <ext:Store ID="Store2" runat="server" AutoLoad="false" IsPagingStore="true" PageSize="25">
                    <Proxy>
                        <ext:PageProxy DirectFn="ContractsCentral.DirectMethods.BindDataCombPrimeVendors">
                            <Reader>
                                <ext:ArrayReader />
                            </Reader>
                        </ext:PageProxy> 
                    </Proxy>
                    <Model>
                        <ext:Model ID="Model16" runat="server">
                            <Fields>
                                <ext:ModelField Name="VEND_CUST_CD" />
                                <ext:ModelField Name="LGL_NM" />
                                <ext:ModelField Name="ccVendorID" />
                            </Fields>
                        </ext:Model>                            
                    </Model>
                </ext:Store>
            </Store>
        </ext:ComboBox>
    </asp:Content>
    == ASPX.vb

        <DirectMethod([Namespace]:="ContractsCentral.DirectMethods")> _
        Public Function BindDataCombPrimeVendors(ByVal action As String, ByVal extraParams As Dictionary(Of String, Object))
            Dim prms As StoreRequestParameters = New StoreRequestParameters(extraParams)
            Dim total As Integer
            Dim data = milestoneCtrl.getVendors(prms.Query.Replace("*", "%"), prms.Start, prms.Limit, total)
    
            Dim reLst As List(Of Object) = New List(Of Object)()
    
            For Each dr As DataRow In data
                reLst.Add(New With { _
                            Key .VEND_CUST_CD = dr.ItemArray(0), _
                          .LGL_NM = dr.ItemArray(1), _
                          .ccVendorID = dr.ItemArray(2) _
                      })
            Next
            Return reLst
        End Function
    == Class file

    Public Function getVendors(ByVal AwardFCPrimeSearch As String, ByVal Start As Integer, ByVal Limit As Integer, ByRef Total As Integer)
            Dim objAdvVend As Vendor = New Vendor()
            objAdvVend.sVendorName = NullToString(AwardFCPrimeSearch)
            objAdvVend.nListType = 1
            Dim dv As System.Data.DataView = objAdvVend.GetAdvantageVendors
            Dim Vendors As DataTable = dv.Table
            Total = Vendors.Rows.Count
    
            Dim data = From vendor In Vendors.AsEnumerable() Skip Start Take Limit Select vendor
    
            Return data.ToList()
    
        End Function

    == Return value on firefox debug page
    <textarea>{result:[
    {"VEND_CUST_CD":"VC0000116939","LGL_NM":"3 HENDRICKS HOMES INC","ccVendorID":0},
    .
    .
    23 records
    .
    .
    {"VEND_CUST_CD":"VC0000026841","LGL_NM":"BROWARD HOMEBOUND PROGRAM INC","ccVendorID":0}]}
    </textarea>
    I don't know why <textarea> tag was added on this ajax return values.
    It looks like combobox doesn't know what data set is.

    Click image for larger version. 

Name:	ComboBox.png 
Views:	17 
Size:	1.7 KB 
ID:	6426
    Last edited by Daniil; Jun 21, 2013 at 3:52 PM. Reason: [CLOSED]
  2. #2
    Hi @kevinhwang,

    Welcome to the Ext.NET forums!

    You should remove the ArrayReader because you bind a collection of objects, not of arrays.

    A response is wrapped in a <textarea>, because, I guess, a file is submitting with a load request. If you don't need to submit any fields, you can set up:
    <ext:PageProxy DirectFn="App.direct.BindData">
        <RequestConfig Type="Load" />
    </ext:PageProxy>
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @kevinhwang,

    Welcome to the Ext.NET forums!

    You should remove the ArrayReader because you bind a collection of objects, not of arrays.

    A response is wrapped in a <textarea>, because, I guess, a file is submitting with a load request. If you don't need to submit any fields, you can set up:
    <ext:PageProxy DirectFn="App.direct.BindData">
        <RequestConfig Type="Load" />
    </ext:PageProxy>
    Hi Daniil,

    Now I can see the records but total property is not loaded and I don't know how I can send back from server side and which configuration I need to set up on ComboBox.
    Could you give me one example?

    Regards,

    Kevin
  4. #4
    Hello!

    You can directly return nameless object with the fields: data and total (this is default names).

    Please, take a look at this example: https://examples2.ext.net/#/GridPane.../DirectMethod/
  5. #5
    Quote Originally Posted by Baidaly View Post
    Hello!

    You can directly return nameless object with the fields: data and total (this is default names).

    Please, take a look at this example: https://examples2.ext.net/#/GridPane.../DirectMethod/
    Thanks Baidaly for your answer.

    It works fine with your recommendation but I had to change some code like below.
    <DirectMethod([Namespace]:="ContractsCentral.DirectMethods")> _
        Public Function BindDataCombPrimeVendors(ByVal action As String, ByVal extraParams As Dictionary(Of String, Object))
            Dim prms As StoreRequestParameters = New StoreRequestParameters(extraParams)
            Dim total As Integer
            Dim dataSorter As DataSorter = prms.Sort(0)
    
            Dim strFilter As String = dataSorter.Property
            Dim strDirection As String = dataSorter.Direction
    
            Dim vendors = milestoneCtrl.getVendors(prms.Query.Replace("*", "%"), prms.Start, prms.Limit, strDirection, strFilter, total)
    
            Dim data As List(Of Object) = New List(Of Object)()
    
            For Each dr As DataRow In vendors
                data.Add(New With { _
                            Key .VEND_CUST_CD = dr.ItemArray(0), _
                          .LGL_NM = dr.ItemArray(1), _
                          .ccVendorID = dr.ItemArray(2) _
                      })
            Next
            Return New With {data, total}
        End Function
    I had to use variable names "data" and "total" instead of using different names when I return back to client.
    My issue is resolved and you can close this ticket.

    Regards,

    Kevin
    Last edited by kevinhwang; Jun 21, 2013 at 3:24 PM.

Similar Threads

  1. Replies: 9
    Last Post: Jan 17, 2013, 5:47 PM
  2. [CLOSED] MVC Templates
    By adelaney in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 16, 2012, 5:04 PM
  3. [CLOSED] Combo with Templates and Ajax
    By deejayns in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 02, 2011, 1:22 PM
  4. Templates column in gridpanel
    By hernanjls in forum 1.x Help
    Replies: 0
    Last Post: Aug 13, 2009, 4:47 PM
  5. Complex Serialization and Templates
    By BrunoC in forum 1.x Help
    Replies: 1
    Last Post: Jan 30, 2009, 1:18 PM

Tags for this Thread

Posting Permissions