PDA

View Full Version : [CLOSED] Add listitem to multiselect use javascript.



gs_user
Jul 13, 2012, 7:04 AM
Hi,

I add multiselect item use javascript, It's can not work.
Where to do wrong?



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

<%@ 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">


</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var setdata = function () {
if (Ck1.checked = true) {
MultiSelect1.store.add(new Ext.data.Record({ text: 'New item', value: 4 }));
}

};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>


<ext:Checkbox ID="Ck1" runat="server" FieldLabel="ITEM1">
<Listeners>
<Change Fn="setdata" ></Change>
</Listeners>
</ext:Checkbox>


<ext:MultiSelect ID="MultiSelect1" runat="server" FieldLabel="" >
<Items>
</Items>
</ext:MultiSelect>

</div>
</form>
</body>
</html>

Daniil
Jul 13, 2012, 7:49 AM
Hi,

Please use:

Example

var setdata = function (checkbox, newValue, oldValue) {
if (newValue) {
var ms = App.MultiSelect1,
rec = {};

rec[ms.displayField] = "New item";
rec[ms.valueField] = new Date().getTime();
ms.getStore().add(rec);
}
};