PDA

View Full Version : [CLOSED] Gridpanel Row selection Issue



WHISHWORKS
Jul 22, 2013, 9:07 AM
Hello,

Actually we are updating Ext.Net new release to our project i.e. 2.2 (Our previous was 2.0).

Gridpanel row selection is not clearing when we select a record in next page. We are not clear where we are doing wrong as it works in our own sample in one page and not working in another page. In my sample code "Openings.aspx" giving issue as it is not clearing row selection when we are moving to different page. Same code works fine in another page i.e. "MasterChildPage.aspx".

As I am unable to attach the sample code please find the link below to download the sample code.

https://docs.google.com/file/d/0Bzbi7rCImjUpWUxWM1poU29jNlU/edit?usp=sharing

RCN
Jul 22, 2013, 12:27 PM
Please post a complete (but simplified) code sample demonstrating how to reproduce the issue.

WHISHWORKS
Jul 22, 2013, 2:08 PM
Hello Raphael,

As I can't attach the sample files here please download zip file from the following URL

https://docs.google.com/file/d/0Bzbi7rCImjUpWUxWM1poU29jNlU/edit?pli=1

Scenario: Select a record in any of the page and navigate to another page and select another record.
Current Behavior : It is not clearing the first selected row.
Expected Behavior : It should clear the first selected row when we select another row in another page.

We have written same code in both the pages but "MasterChildPage.aspx" works perfectly and "Openings.aspx" is not working as expected.

Please let me know any other way where we can upload our code files.


Please post a complete (but simplified) code sample demonstrating how to reproduce the issue.

Daniil
Jul 22, 2013, 3:49 PM
Hi,

You can set up SelectionMemory="false" for a GridPanel. Then selection on the current page will be reset after moving to another page.

WHISHWORKS
Jul 29, 2013, 1:53 PM
Hi,

You can set up SelectionMemory="false" for a GridPanel. Then selection on the current page will be reset after moving to another page.

Hello Daniil,

With this it is clearing selection memory when we move to next page but I want to keep the selection until next record is selected in any of the page.

Daniil
Jul 29, 2013, 3:48 PM
Did it work such a way before in v2.0 and stop in v2.2? Well, if it did, it was a bug in v2.0.

To clear the selection memory (which keeps the selected records of non-current pages) you can call:

grid.clearMemory();

WHISHWORKS
Jul 30, 2013, 4:30 AM
Did it work such a way before in v2.0 and stop in v2.2? Well, if it did, it was a bug in v2.0.

To clear the selection memory (which keeps the selected records of non-current pages) you can call:

grid.clearMemory();

Hello Daniil,

It was working fine in 2.0 as, if we select a record in first page and navigate to next page until we select new record current selection was exists. In the new version when we move to next page and select a new record it is not clearing the previous page selection. But it should not allow as we have enabled single selection. Based on your suggestion we have set selectionmemory to false i.e.
SelectionMemory="false" . Now when we move to next page it is clearing the first page selection. Could you please confirm where we need to add this statement. Please find sample code below



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SampleGrid.aspx.cs" Inherits="Ext.NetSamples.SampleGrid" %>
<%@ Import Namespace="System.Collections.Generic" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<script runat="server">
protected void SubmitSelection(object sender, DirectEventArgs e)
{
string json = e.ExtraParams["Values"];

Dictionary<string, string>[] companies = JSON.Deserialize<Dictionary<string, string>[]>(json);
if (companies.Length == 0)
{
this.Label1.Html = "No Rows selected.";
return;
}

StringBuilder sb = new StringBuilder();
sb.Append("<table cellspacing='15'>");
bool addHeader = true;

foreach (Dictionary<string, string> row in companies)
{
if (addHeader)
{
sb.Append("<tr>");
foreach (KeyValuePair<string, string> keyValuePair in row)
{
sb.Append("<td style='white-space:nowrap;font-weight:bold;padding:5px;'>");

sb.Append(keyValuePair.Key);

sb.Append("</td>");
}
sb.Append("</tr>");

addHeader = false;
}

sb.Append("<tr>");
foreach (KeyValuePair<string, string> keyValuePair in row)
{
sb.Append("<td style='white-space:nowrap;padding:5px;'>");

sb.Append(keyValuePair.Value);

sb.Append("</td>");
}
sb.Append("</tr>");
}
sb.Append("</table>");
this.Label1.Html = sb.ToString();
}
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)
};

this.Store1.DataBind();

if (!this.IsPostBack)
{

}
}


}



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>

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

<link href="/resources/css/examples.css" rel="stylesheet" />

<script>
var template = '<span style="color:{0};">{1}</span>';

var change = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value);
}

var pctChange = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager runat="server" />

<h1>Selection Memory</h1>
<p>This example shows how to maintance selection between paging</p>

<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>
</ext:Store>

<ext:GridPanel
ID="GridPanel1"
runat="server"
StoreID="Store1"
Title="Company List"
Collapsible="true"
Width="600"
Height="350" SelectionMemory="false">
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Company" DataIndex="Name" 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">
<Renderer Fn="change" />
</ext:Column>
<ext:Column runat="server" Text="Change" Width="75" DataIndex="PctChange">
<Renderer Fn="pctChange" />
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Single" />
</SelectionModel>
<View>
<ext:GridView runat="server" StripeRows="true" />
</View>

<BottomBar>
<ext:PagingToolbar runat="server" />
</BottomBar>
</ext:GridPanel>

<div style="width:590px; border:1px solid gray; padding:5px;">
<ext:Label ID="Label1" runat="server" />
</div>

<ext:Button ID="Button1" runat="server" Text="Submit with values">
<DirectEvents>
<Click OnEvent="SubmitSelection">
<ExtraParams>
<ext:Parameter Name="Values" Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOn ly:true}))" Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
</form>
</body>
</html>

Daniil
Jul 30, 2013, 5:20 AM
Thank you for the test case. The key point for me was Mode="Single".

It has been fixed in SVN trunk, please update.