PDA

View Full Version : [CLOSED] GridPanel RowSelectModel don´t working



supera
Jan 23, 2012, 4:38 PM
Hi...

I am doing something wrong, probably!

I declare in my GridPanel the Selection Model as follows



<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Single" />
</SelectionModel>


I have a button, called btnDetails, when i call with DirectEvent the protect sub ShowDetails


<ext:Button runat="server" ID="btnDetails" Icon="ApplicationEdit" Text="Detalhar">
<DirectEvents>
<Click OnEvent="ShowDetails"
Failure="Ext.MessageBox.alert('Load failed', 'Error during ajax event!');">
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{grdSugestoes}.body}" />
</Click>
</DirectEvents>
</ext:Button>


But, in ShowDetail, the collection SelectedRows allways return 0 in count property, although a selected line in the grid



Protected Sub ShowDetails(sender As Object, e As Ext.Net.DirectEventArgs)
Dim sm As Ext.Net.RowSelectionModel = Me.grdSugestoes.GetSelectionModel()
Dim row As Ext.Net.SelectedRow

If sm.SelectedRows.Count > 0 Then
row = sm.SelectedRows(0) 'Pode ter mais de uma selecioanda, mas pego a primeira, sempre
Me.wndSugestoesDetail.Start(Convert.ToInt64(row.Re cordID.ToString), grdSugestoes.GetStore())
Else
Dim msg As New Ext.Net.MessageBox
msg.Alert("REGISTRO NO SELECIONADO", "Por favor, selecione um registro na lista para ver o detalhamento!")
msg.Show()
End If

End Sub

Daniil
Jan 23, 2012, 5:29 PM
Hi,

Confirmed, this is a bug. We will investigate.

Thanks for the report.

For now, I can suggest to send required data via an extra parameter.

Example

<%@ 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)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "test1", "test2", "test3" },
new object[] { "test4", "test5", "test6" },
new object[] { "test7", "test8", "test9" },
};
store.DataBind();
}
}

protected void GetSelectedCount(object sender, DirectEventArgs e)
{
SelectedRowCollection selectedRows = JSON.Deserialize<SelectedRowCollection>(e.ExtraParams["selection"]);
X.Msg.Alert("Count", selectedRows.Count).Show();
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>

<script type="text/javascript">
var getSelection = function (grid) {
var selection = grid.getSelectionModel().getSelection(),
data = [];

Ext.each(selection, function (r) {
data.push({
recordID : r.getId()
});
});
return data;
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server" IDProperty="test1">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Header="Test1" DataIndex="test1" />
<ext:Column runat="server" Header="Test2" DataIndex="test2" />
<ext:Column runat="server" Header="Test3" DataIndex="test3" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Single" />
</SelectionModel>
</ext:GridPanel>
<ext:Button runat="server" Text="Get count of selected rows" OnDirectClick="GetSelectedCount">
<DirectEvents>
<Click OnEvent="GetSelectedCount">
<ExtraParams>
<ext:Parameter
Name="selection"
Value="getSelection(#{GridPanel1})"
Mode="Raw"
Encode="true" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
</form>
</body>
</html>

supera
Jan 23, 2012, 6:49 PM
Hi Daniil

Tested and working fine

Thanks a lot

Daniil
Jan 24, 2012, 12:59 PM
It has been fixed in SVN and will appear in DP2.

Thanks again for the report.