I am wondering how can I filter data using JavaScript?
For example, I would like to output data in JS.
Platform.Load("Core","1");
var layouts = DataExtension.Init("DATA_EXTENSION_NAME").Rows.Retrieve();
Write(Stringify(layouts));
You can also loop access that data through a loop. So if your DE has a field called Email, this should pull that value
for (var i = 0; i < deLength; i++) { var layout = layouts[i]['Email']; }
Hope this helps.
You can filter the data extension rows server side prior to the Write
function using
Platform.Load("Core","1");
var layouts = DataExtension.Init("DATA_EXTENSION_NAME").Rows.Retrieve({Property:"SomeFieldName",SimpleOperator:"equals",Value:"SomeValue"});
Write(Stringify(layouts));
If you are wanting to use the results on the client side you would need to do something like this:
//server side
<script runat="server">
Platform.Load("Core","1");
var layouts = DataExtension.Init("DATA_EXTENSION_NAME").Rows.Retrieve({Property:"SomeFieldName",SimpleOperator:"equals",Value:"SomeValue"});
var layouts = Stringify(layouts);
</script>
//client side
<script>
var layouts = <ctrl:var name=layouts />
</script>
This should now allow you to work with the layouts variable client-side as JSON.