Hybrid View
-
31 Oct 2011 3:43 AM #1
Get CheckboxGridPanel selected rows values, v3.4.0 ?
Get CheckboxGridPanel selected rows values, v3.4.0 ?
I'm using Ext.net 1.2 == ExtJs 3.4.0
I wanna add the selected values (Filter with Name, Lname) to an ext's textbox.
I searched , and I could find the below codes, but now I don't know how I can add the the values from var values in JavaScript to an ext's textbox.
Could you please guide me ? ThanksCode:<script type="text/javascript"> function AddUser() { var values = GridPanel1.getRowsValues( { filterField: function (record, fieldName, value) {return fieldName == "Name" || fieldName == "Lname";}, selectedOnly: true, currentPageOnly: false }); ////this method should be complete } </script> <div style="width: 500px; margin: 0 auto;"> <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData"> <Reader> <ext:JsonReader IDProperty="ID"> <Fields> <ext:RecordField Name="ID" Type="Int" /> <ext:RecordField Name="RowNumber" Type="Int" /> <ext:RecordField Name="Name" /> <ext:RecordField Name="Lname" /> <ext:RecordField Name="EnterprisePosition" /> </Fields> </ext:JsonReader> </Reader> </ext:Store> <br /> <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true" Title="Result" Collapsible="true" StyleSpec="width:95%; margin:0 auto;" Height="350" Collapsed="true"> <ColumnModel ID="ColumnModel1" runat="server"> <Columns> <ext:Column ColumnID="RowNumber" Header="Row" Width="50" Resizable="false" MenuDisabled="true" Fixed="true" DataIndex="RowNumber" /> <ext:Column ColumnID="Name" Header="Name" Width="100" DataIndex="Name" /> <ext:Column Header="Last Name" Width="150" DataIndex="Lname" /> <ext:Column Header="Position" Width="160" DataIndex="EnterprisePosition" /> </Columns> </ColumnModel> <BottomBar> <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="10" StoreID="Store1" DisplayInfo="false" /> </BottomBar> <SelectionModel> <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server"> <Listeners> <RowSelect Fn="AddUser" /><!-- ******** --> </Listeners> </ext:CheckboxSelectionModel> </SelectionModel> </ext:GridPanel> </div>
-
31 Oct 2011 4:39 AM #2
how to get values from Grid rows
how to get values from Grid rows
well....I dont know abt extjs 3.4 version
but m using extjs4.0 and at first I got the same problem..........but now here is the solution
try it in ur code
put this particular code : where u want to call the form component
for example:
I want this value when I check the row and click on EDIT button:
So this code has to cum inside the
through this u get the value of NAME n LNAMECode:buttons:[{ text: 'EDIT', handler: function{ var sm = Ext.getCmp('grid_ID').getSelectionModel(); var rec=sm.getLastSelected(); // for name and last name get the values from grid Selection first_name = rec.get("first_name"); last_name = rec.get("last_name"); } }]
now put value: first_name and value: last_name where u have given :
n same for last name:Code:xtype: 'textfield', id: 'first_name', name: 'first_name', fieldlabel: 'First Name', value : first_name
Code:xtype: 'textfield', id: 'last_name', name: 'last_name', fieldlabel: 'Last Name', value : last_name
Last edited by poojagarg89; 31 Oct 2011 at 4:43 AM. Reason: forgot something to write
-
31 Oct 2011 4:59 AM #3
I wanna all selected rows
I wanna all selected rows
Thanks for your reply.
You wrote in your code :
That give us only the last selected row details, whereas I wanna get all selected rows' values !!!PHP Code:var rec=sm.getLastSelected();
How can I get all selected rows' values ?
-
31 Oct 2011 5:21 AM #4
hey this thing m also searching even I have posted a new thread for getting all selected rows of a grid
but the code I was trying to execute may work with u as of ur working on extjs 3.x version
this will give u the selected rows of the grid by getSelections() method and the count of rows by getCount() methodCode:var count=Ext.getCmp('grid_id').getSelectionModel().getCount(); var lst=Ext.getCmp('grid_id').getSelectionModel().getSelections();
this code is not working for me as m using extjs 4.0 version
hopefully it will work for u try this.............!Last edited by poojagarg89; 31 Oct 2011 at 5:23 AM. Reason: forgot something to write
-
31 Oct 2011 9:40 PM #5
Solved
Solved
Thanks, My problem was solved.

The final code is following :
Code:<script type="text/javascript"> function AddUser() { Ext.getCmp('TextFieldReceivers').setValue(""); var count = Ext.getCmp('GridPanel1').getSelectionModel().getCount(); var lst = Ext.getCmp('GridPanel1').getSelectionModel().getSelections(); var textfiled = Ext.getCmp('TextFieldReceivers'); for (var i = 0; i < count; i++) { textfiled.setValue(textfiled.value + lst[i].data.Name + " " + lst[i].data.Lname + ","); } } </script> <div style="text-align: center; padding: 3px;"> <span style="font-weight: bold; font-family: Arial, Helvetica, sans-serif; font-size: 18px;"> جستجو کاربران </span> <br /> <div style="width: 500px; margin: 0 auto;"> <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData"> <Reader> <ext:JsonReader IDProperty="ID"> <Fields> <ext:RecordField Name="ID" Type="Int" /> <ext:RecordField Name="RowNumber" Type="Int" /> <ext:RecordField Name="Name" /> <ext:RecordField Name="Lname" /> <ext:RecordField Name="EnterprisePosition" /> </Fields> </ext:JsonReader> </Reader> </ext:Store> <br /> <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true" Title="نتیجه جستجو" Collapsible="true" StyleSpec="width:95%; margin:0 auto;" Height="350" Collapsed="true"> <ColumnModel ID="ColumnModel1" runat="server"> <Columns> <ext:Column ColumnID="ID" DataIndex="ID" Hidden="true" /> <ext:Column ColumnID="RowNumber" Header="ردیف" Width="50" Resizable="false" MenuDisabled="true" Fixed="true" DataIndex="RowNumber" /> <ext:Column ColumnID="Name" Header="نام" Width="100" DataIndex="Name" /> <ext:Column Header="نام خانوادگی" Width="130" DataIndex="Lname" /> <ext:Column Header="جایگاه سازمانی" Width="140" DataIndex="EnterprisePosition" /> </Columns> </ColumnModel> <BottomBar> <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="10" StoreID="Store1" DisplayInfo="false" /> </BottomBar> <SelectionModel> <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server"> <Listeners> <RowSelect Fn="AddUser"></RowSelect> <RowDeselect Fn="AddUser"></RowDeselect> </Listeners> </ext:CheckboxSelectionModel> </SelectionModel> </ext:GridPanel> </div>
-
31 Oct 2011 9:46 PM #6


Reply With Quote
mention not