PDA

View Full Version : [CLOSED] Request: Add DataView.Select(id as object)



jchau
Mar 21, 2013, 3:49 PM
It will be nice to do:



dim targetID = ""
myDataView.Select(targetID)


vs



dim targetID = ""
myDataView.Select(new Ext.net.ModelProxy() { myDataView.GetStore().GetById(targetID) })


seems like more often, we want to select by id vs by array of modelproxy, especially since during directmethod, we usually just the ID and not the model record.

Daniil
Mar 21, 2013, 5:38 PM
Hi @jchau,

Thank you for the request. We will implement.

Methods applying an IEnumerable of indexes and ids would be also helpful.

Daniil
Mar 22, 2013, 8:30 AM
The methods were added to the SVN trunk and will be included to the next release.

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.DataView1.GetStore();
store.DataSource = new object[]
{
new object[] { "test1" },
new object[] { "test2" },
new object[] { "test3" },
new object[] { "test4" },
new object[] { "test5" }
};
store.DataBind();
}
}

protected void Select1(object sender, DirectEventArgs e)
{
this.DataView1.Select(new int[] { 0, 2 });
}

protected void Select2(object sender, DirectEventArgs e)
{
this.DataView1.Select(new List<object>() { "test2", "test4" });
}

protected void Select3(object sender, DirectEventArgs e)
{
this.DataView1.Select("test5");
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET Example</title>

<style>
.my-dataview .x-item-selected {
background-color: gray;
}
</style>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:DataView
ID="DataView1"
runat="server"
Cls="my-dataview"
MultiSelect="true"
ItemSelector="div.my-item">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server" IDProperty="test">
<Fields>
<ext:ModelField Name="test" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Tpl runat="server">
<Html>
<tpl for=".">
<div class="my-item">{test}</div>
</tpl>
</Html>
</Tpl>
</ext:DataView>

<ext:Button runat="server" Text="Select by indexes" OnDirectClick="Select1" />

<ext:Button runat="server" Text="Select by ids" OnDirectClick="Select2" />

<ext:Button runat="server" Text="Select by id" OnDirectClick="Select3" />
</form>
</body>
</html>