PDA

View Full Version : [CLOSED] selectAll attribute not work in gridpanel



JCarlosF
Apr 24, 2013, 8:44 PM
I have a window with many gridpanel:

6099

I want to select all items, but does not work,
I do like this:


Protected Sub btnCancelarF_click(sender As Object, e As DirectEventArgs)
Dim smA As CheckboxSelectionModel = TryCast(Me.GridPanelArea.GetSelectionModel(), CheckboxSelectionModel)
Dim smDep As CheckboxSelectionModel = TryCast(Me.GridPanelDeptos.GetSelectionModel(), CheckboxSelectionModel)
Dim smL As CheckboxSelectionModel = TryCast(Me.GridPanelLoc.GetSelectionModel(), CheckboxSelectionModel)
Dim smCC As CheckboxSelectionModel = TryCast(Me.GridPanelCC.GetSelectionModel(), CheckboxSelectionModel)
Dim smPer As CheckboxSelectionModel = TryCast(Me.GridPanelPeriod.GetSelectionModel(), CheckboxSelectionModel)
Dim smDiv As CheckboxSelectionModel = TryCast(Me.GridPanelDiv.GetSelectionModel(), CheckboxSelectionModel)
Dim smPues As CheckboxSelectionModel = TryCast(Me.GridPanelPuesto.GetSelectionModel(), CheckboxSelectionModel)

smA.SelectAll()
smA.UpdateSelection()
smPer.SelectAll()
smPer.UpdateSelection()
smCC.SelectAll()
smCC.UpdateSelection()
smDep.SelectAll()
smDep.UpdateSelection()
smL.SelectAll()
smL.UpdateSelection()
smDiv.SelectAll()
smDiv.UpdateSelection()
smPues.SelectAll()
smPues.UpdateSelection()


End Sub

Vladimir
Apr 24, 2013, 8:55 PM
UpdateSelection is not requuired after SelectAll, UpdateSelection must be called after modifing SelectedRows collection

JCarlosF
Apr 24, 2013, 9:39 PM
UpdateSelection is not requuired after SelectAll, UpdateSelection must be called after modifing SelectedRows collection

already applied, and does not work


sideclient:


<ext:Button ID="btnCancelarF" runat="server" Text="Cancelar" Icon="Cancel" >
<DirectEvents>
<Click OnEvent ="btnCancelarF_click" />
</DirectEvents>
</ext:Button>


codebehind:



Protected Sub btnCancelarF_click(sender As Object, e As DirectEventArgs)
Dim smA As CheckboxSelectionModel = TryCast(Me.GridPanelArea.GetSelectionModel(), CheckboxSelectionModel)
Dim smDep As CheckboxSelectionModel = TryCast(Me.GridPanelDeptos.GetSelectionModel(), CheckboxSelectionModel)
Dim smL As CheckboxSelectionModel = TryCast(Me.GridPanelLoc.GetSelectionModel(), CheckboxSelectionModel)
Dim smCC As CheckboxSelectionModel = TryCast(Me.GridPanelCC.GetSelectionModel(), CheckboxSelectionModel)
Dim smPer As CheckboxSelectionModel = TryCast(Me.GridPanelPeriod.GetSelectionModel(), CheckboxSelectionModel)
Dim smDiv As CheckboxSelectionModel = TryCast(Me.GridPanelDiv.GetSelectionModel(), CheckboxSelectionModel)
Dim smPues As CheckboxSelectionModel = TryCast(Me.GridPanelPuesto.GetSelectionModel(), CheckboxSelectionModel)

smA.SelectAll()
smPer.SelectAll()
smCC.SelectAll()
smDep.SelectAll()
smL.SelectAll()
smDiv.SelectAll()
smPues.SelectAll()

End Sub


this code window:



<ext:Window
ID="WindowsFiltros"
runat="server"
Closable="true"
Resizable="false"
Height="480"
Draggable="false"
Width="520"
Hidden ="true"
Modal="true"
Title="Filtros" Layout="Fit" >



thanks!

Vladimir
Apr 24, 2013, 10:06 PM
Please provide test case
The single assumption that you try to select all records in a grid which are not rendered yet (in inactive tabs)
If it is true then you need to set DeferredRender="false" for TabPanel

Here is my test case


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>


<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = this.Data;
this.Store1.DataBind();


this.Store2.DataSource = this.Data;
this.Store2.DataBind();


this.Store3.DataSource = this.Data;
this.Store3.DataBind();
}
}


private object[] Data
{
get
{
return new object[]
{
new object[] { "3m Co" },
new object[] { "Alcoa Inc" },
new object[] { "Altria Group Inc" }
};
}
}


protected void SelectAll_DirectClick(object sender, DirectEventArgs e)
{
GridPanel1.SelectionModel.Primary.SelectAll();
GridPanel2.SelectionModel.Primary.SelectAll();
GridPanel3.SelectionModel.Primary.SelectAll();
}
</script>


<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Test Page </title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<ext:Window runat="server"
Width="400"
Height="300"
Layout="FitLayout">
<Items>
<ext:TabPanel runat="server" DeferredRender="false">
<Items>
<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Grid1">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" />
</SelectionModel>
</ext:GridPanel>


<ext:GridPanel
ID="GridPanel2"
runat="server"
Title="Grid2">
<Store>
<ext:Store ID="Store2" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" />
</SelectionModel>
</ext:GridPanel>


<ext:GridPanel
ID="GridPanel3"
runat="server"
Title="Grid3">
<Store>
<ext:Store ID="Store3" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" />
</SelectionModel>
</ext:GridPanel>
</Items>
</ext:TabPanel>
</Items>
<Buttons>
<ext:Button runat="server" Text="Select All" OnDirectClick="SelectAll_DirectClick" />
</Buttons>
</ext:Window>
</form>
</body>
</html>

JCarlosF
Apr 24, 2013, 10:59 PM
Please provide test case
The single assumption that you try to select all records in a grid which are not rendered yet (in inactive tabs)
If it is true then you need to set DeferredRender="false" for TabPanel

Here is my test case


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>


<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = this.Data;
this.Store1.DataBind();


this.Store2.DataSource = this.Data;
this.Store2.DataBind();


this.Store3.DataSource = this.Data;
this.Store3.DataBind();
}
}


private object[] Data
{
get
{
return new object[]
{
new object[] { "3m Co" },
new object[] { "Alcoa Inc" },
new object[] { "Altria Group Inc" }
};
}
}


protected void SelectAll_DirectClick(object sender, DirectEventArgs e)
{
GridPanel1.SelectionModel.Primary.SelectAll();
GridPanel2.SelectionModel.Primary.SelectAll();
GridPanel3.SelectionModel.Primary.SelectAll();
}
</script>


<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Test Page </title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<ext:Window runat="server"
Width="400"
Height="300"
Layout="FitLayout">
<Items>
<ext:TabPanel runat="server" DeferredRender="false">
<Items>
<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Grid1">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" />
</SelectionModel>
</ext:GridPanel>


<ext:GridPanel
ID="GridPanel2"
runat="server"
Title="Grid2">
<Store>
<ext:Store ID="Store2" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" />
</SelectionModel>
</ext:GridPanel>


<ext:GridPanel
ID="GridPanel3"
runat="server"
Title="Grid3">
<Store>
<ext:Store ID="Store3" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="company" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" />
</SelectionModel>
</ext:GridPanel>
</Items>
</ext:TabPanel>
</Items>
<Buttons>
<ext:Button runat="server" Text="Select All" OnDirectClick="SelectAll_DirectClick" />
</Buttons>
</ext:Window>
</form>
</body>
</html>



works great, but if you want to put in the load, not working:



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Ext.Net.X.IsAjaxRequest Then
CargarGridFiltrosNomina() 'this loads the grids
TabPanel1.ActiveTabIndex = 0

Dim smA As CheckboxSelectionModel = TryCast(Me.GridPanelArea.GetSelectionModel(), CheckboxSelectionModel)
Dim smDep As CheckboxSelectionModel = TryCast(Me.GridPanelDeptos.GetSelectionModel(), CheckboxSelectionModel)
Dim smL As CheckboxSelectionModel = TryCast(Me.GridPanelLoc.GetSelectionModel(), CheckboxSelectionModel)
Dim smCC As CheckboxSelectionModel = TryCast(Me.GridPanelCC.GetSelectionModel(), CheckboxSelectionModel)
Dim smPer As CheckboxSelectionModel = TryCast(Me.GridPanelPeriod.GetSelectionModel(), CheckboxSelectionModel)
Dim smDiv As CheckboxSelectionModel = TryCast(Me.GridPanelDiv.GetSelectionModel(), CheckboxSelectionModel)
Dim smPues As CheckboxSelectionModel = TryCast(Me.GridPanelPuesto.GetSelectionModel(), CheckboxSelectionModel)

smA.SelectAll()
smPer.SelectAll()
smCC.SelectAll()
smDep.SelectAll()
smL.SelectAll()
smDiv.SelectAll()
smPues.SelectAll()

End If
End Sub



any suggestions?

thanks!

Daniil
Apr 25, 2013, 5:55 AM
Hi,

Calling .SelectAll() for a non-rendered GridPanel is too early.

Selecting should be done on the ViewReady event.

GridPanel1.Listeners.ViewReady.Handler = "this.getSelectionModel().selectAll();";
GridPanel2.Listeners.ViewReady.Handler = "this.getSelectionModel().selectAll();";
GridPanel3.Listeners.ViewReady.Handler = "this.getSelectionModel().selectAll();";

JCarlosF
Apr 29, 2013, 3:34 PM
Hi,

Calling .SelectAll() for a non-rendered GridPanel is too early.

Selecting should be done on the ViewReady event.

GridPanel1.Listeners.ViewReady.Handler = "this.getSelectionModel().selectAll();";
GridPanel2.Listeners.ViewReady.Handler = "this.getSelectionModel().selectAll();";
GridPanel3.Listeners.ViewReady.Handler = "this.getSelectionModel().selectAll();";


ok, thanks!

blueworld
Dec 05, 2013, 3:51 PM
Hi everyone,

I call the selectAll after store load, this works fine.


<Listeners>
<Load Handler="#{GridPanelQuickRelease}.getSelectionModel().selec tAll();" />
</Listeners>


I have a checkbox selectionmodel, and the problem is, that the header-checkbox is not checked then. Any idea how to fix that?

Baidaly
Dec 05, 2013, 7:20 PM
Hello!

Couldn't reproduce this issue. Tried the sample below:


<%@ Page Language="C#" %>

<%@ Import Namespace="System.Collections.Generic" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new List<Company>
{
new Company(0, "3m Co", 71.72, 0.02, 0.03),
new Company(1, "Alcoa Inc", 29.01, 0.42, 1.47),
new Company(2, "Altria Group Inc", 83.81, 0.28, 0.34),
new Company(3, "American Express Company", 52.55, 0.01, 0.02),
new Company(4, "American International Group, Inc.", 64.13, 0.31, 0.49),
new Company(5, "AT&T Inc.", 31.61, -0.48, -1.54),
new Company(6, "Boeing Co.", 75.43, 0.53, 0.71),
new Company(7, "Caterpillar Inc.", 67.27, 0.92, 1.39),
new Company(8, "Citigroup, Inc.", 49.37, 0.02, 0.04),
new Company(9, "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28),
new Company(10, "Exxon Mobil Corp", 68.1, -0.43, -0.64),
new Company(11, "General Electric Company", 34.14, -0.08, -0.23),
new Company(12, "General Motors Corporation", 30.27, 1.09, 3.74),
new Company(13, "Hewlett-Packard Co.", 36.53, -0.03, -0.08),
new Company(14, "Honeywell Intl Inc", 38.77, 0.05, 0.13),
new Company(15, "Intel Corporation", 19.88, 0.31, 1.58),
new Company(16, "International Business Machines", 81.41, 0.44, 0.54),
new Company(17, "Johnson & Johnson", 64.72, 0.06, 0.09),
new Company(18, "JP Morgan & Chase & Co", 45.73, 0.07, 0.15),
new Company(19, "McDonald\"s Corporation", 36.76, 0.86, 2.40),
new Company(20, "Merck & Co., Inc.", 40.96, 0.41, 1.01),
new Company(21, "Microsoft Corporation", 25.84, 0.14, 0.54),
new Company(22, "Pfizer Inc", 27.96, 0.4, 1.45),
new Company(23, "The Coca-Cola Company", 45.07, 0.26, 0.58),
new Company(24, "The Home Depot, Inc.", 34.64, 0.35, 1.02),
new Company(25, "The Procter & Gamble Company", 61.91, 0.01, 0.02),
new Company(26, "United Technologies Corporation", 63.26, 0.55, 0.88),
new Company(27, "Verizon Communications", 35.57, 0.39, 1.11),
new Company(28, "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63)
};
}
}

public class Company
{
public Company(int id, string name, double price, double change, double pctChange)
{
this.ID = id;
this.Name = name;
this.Price = price;
this.Change = change;
this.PctChange = pctChange;
}

public int ID { get; set; }
public string Name { get; set; }
public double Price { get;set; }
public double Change { get;set; }
public double PctChange { get;set; }
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Company List"
Collapsible="true"
Width="600">
<Store>
<ext:Store ID="Store1" runat="server" PageSize="10">
<Model>
<ext:Model runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Name" />
<ext:ModelField Name="Price" />
<ext:ModelField Name="Change" />
<ext:ModelField Name="PctChange" />
</Fields>
</ext:Model>
</Model>
<Listeners>
<Load Handler="#{GridPanel1}.getSelectionModel().selectAll(); " />
</Listeners>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column
runat="server"
Text="Company"
Width="160"
DataIndex="Name"
Resizable="false"
MenuDisabled="true"
Flex="1" />

<ext:Column runat="server" Text="Price" Width="75" DataIndex="Price">
<Renderer Format="UsMoney" />
</ext:Column>

<ext:Column runat="server" Text="Change" Width="75" DataIndex="Change">
</ext:Column>

<ext:Column runat="server" Text="Change" Width="75" DataIndex="PctChange">
</ext:Column>
</Columns>
</ColumnModel>
<BottomBar>
<ext:PagingToolbar runat="server" DisplayInfo="false">
</ext:PagingToolbar>
</BottomBar>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" Mode="Multi" />
</SelectionModel>
</ext:GridPanel>
</form>
</body>
</html>

blueworld
Dec 06, 2013, 8:40 AM
Hi Baidaly,

the following code is similar to my real code, and at least here, it does not work:
Press the "Show Window" button.





<%@ Page Language="VB" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title></title>

<script runat="server">
Private Class TestObject
Public Property PropName As String
End Class

Protected Sub ResultsStore_RefreshData(ByVal sender As Object, ByVal e As Ext.Net.StoreReadDataEventArgs) Handles StoreQuickRelease.ReadData

Dim xx As New Generic.List(Of TestObject)
For counter = 0 To 20
Dim testObject As New TestObject

testObject.PropName = "Name" + counter.ToString()

xx.Add(testObject)
Next

StoreQuickRelease.DataSource = xx
StoreQuickRelease.DataBind()

End Sub



</script>

<style>

</style>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<ext:Viewport ID="Viewport1" runat="server" Layout="borderLayout">
<Items>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="Button1" runat="server" Text="Show Window">
<Listeners>
<Click Handler="#{WindowQuickRelease}.show();#{StoreQuickRelease}. reload();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
<ext:Window ID="WindowQuickRelease" runat="server"
Title="TestWindow"
Width="600"
Height="400"
MinWidth="300"
MinHeight="200"
Layout="FitLayout" Hidden="true">
<Items>
<ext:GridPanel
ID="GridPanelQuickRelease"
runat="server"
MultiSelect="true"
ForceFit="true"
Border="false"
Header="false">
<Store>
<ext:Store ID="StoreQuickRelease" runat="server">
<Model>
<ext:Model ID="Model8" runat="server">
<Fields>
<ext:ModelField Name="PropName" Type="String" />
</Fields>
</ext:Model>
</Model>
<Listeners>
<Load Handler="#{GridPanelQuickRelease}.getSelectionModel().selec tAll();" />
</Listeners>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" Text="Name" DataIndex="PropName" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel ID="RowSelectionModel2" runat="server" Mode="multi">
</ext:CheckboxSelectionModel>
</SelectionModel>
<View>
<ext:GridView ID="GridView2" runat="server" EnableTextSelection="false">
</ext:GridView>
</View>
</ext:GridPanel>
</Items>
</ext:Window>

</Items>
</ext:Viewport>
</form>
</body>
</html>

Daniil
Dec 06, 2013, 8:56 AM
There is a JavaScript occurs.

Selection should not be done before a GridPanel's or GridView's ViewReady event.