[CLOSED] MVC GridPanel Databinding

  1. #1

    [CLOSED] MVC GridPanel Databinding

    Is there a way to set a "proxy method" each for Insert, Read, Update & Delete? I see that you have ".Reader" and ".Writer" by default, but I would really like to have some flexibilty with that if possible. For example, my reader method can take an ID parameter and I would like to be able to use a dropdown to select different employee IDs and then rebind/filter my grid. Also, I have to perform different data manipulations on various data elements and those are different whether the action at hand is an update vs. an insert. At any rate, here is my grid configuration. Any advice is appreciated.


    Html.X.GridPanel().ID("TeamGrid").ColumnModel(Sub(cols)
                                                            cols.Add(Html.X.Column().DataIndex("CWTeamID").Hidden(True))
                                                            cols.Add(Html.X.Column().DataIndex("Name").Text("Team").Flex(1))
                                                            cols.Add(Html.X.Column().DataIndex("DrafterEmployeeID").Text("Drafter1"))
                                                            cols.Add(Html.X.Column().DataIndex("ReviewerEmployeeID").Text("Reviewer"))
                                                            cols.Add(Html.X.Column().DataIndex("CorrespondentEmployeeID").Text("Correspondent"))
                                                            cols.Add(Html.X.Column().DataIndex("QAReviewerEmployeeID").Text("QA Reviewer"))
                                                            cols.Add(Html.X.CommandColumn().Text("Manage").Flex(1).Commands(Sub(commands)
                                                                                                                                commands.Add(New Ext.Net.GridCommand() With {.Icon = Icon.Pencil, .Text = "Edit"})
                                                                                                                                commands.Add(New Ext.Net.GridCommand() With {.Text = "Cedents"})
                                                                                                                            End Sub))
                                                        End Sub) _
                                                  .Store(Sub(str)
                                                                 str.Add(Html.X.Store().ID("tmStore").AutoLoad(True) _
                                                                         .Model(Sub(mdl)
                                                                                        mdl.Add(Html.X().Model.Fields(Sub(fields)
                                                                                                                              fields.Add(Html.X.ModelField.Name("CWTeamID").Type(ModelFieldType.Int))
                                                                                                                              fields.Add(Html.X.ModelField.Name("Name"))
                                                                                                                              fields.Add(Html.X.ModelField.Name("DrafterEmployeeID").Type(ModelFieldType.Int))
                                                                                                                              fields.Add(Html.X.ModelField.Name("ReviewerEmployeeID").Type(ModelFieldType.Int))
                                                                                                                              fields.Add(Html.X.ModelField.Name("CorrespondentEmployeeID").Type(ModelFieldType.Int))
                                                                                                                              fields.Add(Html.X.ModelField.Name("QAReviewerEmployeeID").Type(ModelFieldType.Int))
                                                                                                                      End Sub))
                                                                                End Sub) _
                                                                          .Proxy(Sub(proxy)
                                                                                         proxy.Add(Html.X.AjaxProxy().Url(Url.Content("~/Assignments") + "/_GetTeams/" + MvcApplication.CurrentApplicationUser.EmployeeID.ToString()) _
                                                                                                     .Reader(Sub(rdr)
                                                                                                                     rdr.Add(Html.X.JsonReader().Root("Data"))
                                                                                                             End Sub) _
                                                                                                         .Writer(Sub(wrtr)
                                                                                                                         wrtr.Add(Html.X.JsonWriter().Root("Data"))
                                                                                                                 End Sub))
                                                                                 End Sub) _
                                                                         .PageSize(20))
                                                         End Sub) _
                                                     .Listeners(Sub(lstner)
                                                                        lstner.SelectionChange().Fn = "RowSelected"
                                                                End Sub) _
                                                  .Loader(Sub(ldr)
                                                                  ldr.Enabled() = True
                                                          End Sub) _
                                                  .Plugins(Sub(plug)
                                                                   plug.Add(New Ext.Net.RowEditing() With {.AutoCancel = False, .ClicksToMoveEditor = 1, .AutoDataBind = True, .SaveBtnText = "Update"})
                                                           End Sub) _
                                                  .TopBar(Sub(tb)
                                                                  Dim tbar As New Ext.Net.Toolbar
                                                                  Dim btn As New Ext.Net.Button() With {.ID = "btnAddTeam", .Text = "Add Team"}
                                                                  btn.Listeners.Click.Fn = "addTeam"
                                                                  
                                                                  tbar.Items.Add(btn)
                                                                  tb.Add(tbar)
                                                          End Sub) _
                                                  .Selectable(True)
    Just to be clear, my goal is to use URL routes like so:
    /Assignments/_GetTeams/1
    /Assignments/_GetTeams/121
    /Assignments/_EditTeams/1
    /Assignments/_DeleteTeams/1
    /Assignments/_NewTeam/
    Last edited by Daniil; May 18, 2012 at 6:01 PM. Reason: [CLOSED]
  2. #2
    You should use the API property of the AjaxProxy class, it exposes the Create/Destroy/Read/Update properties that you can bind your URLs for. That is how you would handle a true RESTful pattern with the store.

    Cheers,
    Timothy
  3. #3
    Hi,

    Please use the AjaxProxy API.
    http://docs.sencha.com/ext-js/4-1/#!...Server-cfg-api

Similar Threads

  1. gridpanel databinding
    By svk in forum 1.x Help
    Replies: 6
    Last Post: May 06, 2012, 5:15 PM
  2. Replies: 0
    Last Post: Jun 21, 2011, 3:51 AM
  3. help with databinding (ext:GridPanel)
    By vikram1983 in forum 1.x Help
    Replies: 2
    Last Post: Apr 05, 2011, 2:07 PM
  4. DataBinding GridPanel/Store/Reader
    By nuno_Santos in forum 1.x Help
    Replies: 4
    Last Post: Apr 01, 2009, 3:18 PM
  5. GridPanel DataBinding
    By Timothy in forum 1.x Premium Help
    Replies: 2
    Last Post: Nov 13, 2008, 11:24 PM

Tags for this Thread

Posting Permissions