Radzen data grid dynamic data and values - datagrid

I am needing to be able to generate columns and values from dynamic data. My model is a List that contains a string and another list. The string is the column name, which I can get to display correctly. The list however I have not been able to get working correctly. I am getting one of three things all the time. 1) No values 2) The control name 3) The values but the values for each Column level item.
So with 3 columns and each column having 3 data point I can generate all three columns, but I get all three columns worth of data in each column.
Below is the code I am using for the data grid it's self as well as the code for adding the data to the outer and inner lists.
If anyone has any ideas of how to complete this I could really use the help at this point.
public List<rdzTest> getData()
{
for(int i = 0; i<5; i++)
{
rdzTest rt = new rdzTest();
//rt.name = new List<string>();
rt.name = "Property Name " + " -- " + i.ToString();
rt.values = new List<string>();
string s = "";// "<ul>";
for (int j = 0; j < 10; j++)
{
//s += "<li>values " + j.ToString() + " Property -- " + i.ToString() + "</li>";
s = "values " + j.ToString() + " Property -- " + i.ToString();
rt.values.Add(s);
}
//s += "</ul>";
//rt.values = s;
alpha.Add(rt);
//alpha.name = rt.name;
//alpha.values = rt.values;
}
return alpha;
}
<RadzenDataGrid TItem="rdzTest" Col Data=#alpha>
<Columns>
#foreach(rdzTest rt in alpha)
{
<RadzenDataGridColumn TItem="rdzTest" Property=#rt.name Title="#rt.name">
<Template>
<ul>
#foreach(string st in rt.values)
{
<li>
#st
</li>
}
</ul>
</Template>
</RadzenDataGridColumn>
}
</Columns>
</RadzenDataGrid>

Related

put csv data to array imacros js

I am trying to loop through a csv file pushing each column into an array but I am not sure how to do that, I know that the tag {{!COL1}} will give me the data I want but I can't figure out how to save it into a variable I can use to push inside an array.
csvToArray = "CODE:";
csvToArray += "SET !DATASOURCE artist.csv" + "\n";
csvToArray += "SET !ERRORIGNORE YES" + "\n";
csvToArray += "SET !DATASOURCE_LINE {{CSV}}" + "\n";
csvToArray += "SET !VAR1 {{!COL1}}" + "\n";
for(i = 0; i < 10; i++){
iimSet("CSV", i);
iimPlay(csvToArray);
}
This code will allow me to loop through a csv file, and the {{!COL1}} tag gives me the data i want, how do i save this into a varialbe i can use, please someone help cant figure this one out. :(
To get the data of COL1 you will need to set EXTRACT = COL1, then assign your variable to iimGetLastExtract().
Add this to your macro:
csvToArray += "SET !EXTRACT {{!COL1}}";
Then add this to your js file:
var myArray = []; // place at top of file for readability
myArray.push(iimGetLastExtract()); // place at end of for loop
// puts each extraction into myArray
Try the below code block.
function read_file(path) {
var content = '', i = 1, f, res = '',spl;
while (1){
content = res;
if (content != "") {
spl = content.split("|");
//spl[0] will contain the Row1 and Column1 value, spl[1] will contain Row 1 and Column 2 value etc.,
/*Here you can specify your script/conditions
Example:
iimPlay('CODE:TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:login[username] CONTENT='+spl[0]);
iimPlay('CODE:TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:login[password] CONTENT='+spl[1]);
I used the infinite loop, so in order to come out of the loop, you need to add a condition like below
if (spl[0]=="End") {//In your input sheet if the Row1,Col1 contains the value 'End', then it will exit the loop
iimDisplay("All Rows Completed");
return;
}
*/
f = "CODE: "+"\n";
f += "SET !EXTRACT null" + "\n";
f += "SET !LOOP 3" + "\n";
f += "SET !DATASOURCE \""+path+"\" "+"\n";
f += "SET !DATASOURCE_COLUMNS 5" + "\n"; //Assume that you have five columns in the your input file
f += "SET !DATASOURCE_LINE " + i + "\n";
f += "SET !EXTRACT {{!col1}}|{{!col2}}|{{!col3}}|{{!col4}}|{{!col5}}" + "\n";
iimPlay(f);
res = iimGetLastExtract();
i++;
}
return content;
}
var file_conten = read_file("yourinputfilename.csv");

how to select all grid items in foreach loop in telerik asp

This code shows me null value. In fact I have 4 rows in the grid count, but the problem is that it's showing me null value.
// loops through each row in RadGrid
foreach (GridDataItem row in RadGrid.MasterTableView.Items)
{
Table = Table + row["Columns_Name"].Text.ToString() + " ";
Table = Table + row["My_data_type"].Text.ToString() + " ";
Table = Table + row["Col_Primary_Key"].Text.ToString() + " ";
Table = Table + row["Null_NotNull"].Text.ToString() + "\n,";
}
string value = item.Cells[0].Text; //take the value from the first columns of each row

specific distance between columns of drop down list

i like to have 2 columns in my drop down list with specific distance between 2 columns, so i have added below code but columns are not align with my code.
var query = from p in _DataContext.tblDocuments
orderby p.DocumentNo
select new
{
Doctitle = p.DocumentNo+' '+' '+"|"+' '+p.TITLE,
DocId = p.DocId
};
ddlProjectDocument.DataSource = query;
ddlProjectDocument.DataValueField = "DocId";
ddlProjectDocument.DataTextField = "Doctitle";
ddlProjectDocument.DataBind();
please help how i can have 2 columns with normal view and good align.
The alignment will depend on the length of the value in the field of your table. One way to do it would be to get the size of the largest entry in your table and make sure that all entries are that wide. Here is something you can try.
<asp:DropDownList ID="ddlStack" runat="server" OnLoad="ddlStack_Load" />
and in the source code for ddl load event:
protected void ddlStack_Load(object sender, EventArgs e)
{
var all = from o in _DataContext.tblDocuments
orderby o.DocumentNo
select o;
int maxs = 0;
foreach (tblDocuments v in all)
{
if (v.DocumentNo.Length > maxs)
maxs = v.DocumentNo.Length;
}
foreach (tblDocuments vv in all)
{
string doctitle = vv.DocumentNo;
for (int i = vv.DocumentNo.Length; i < maxs + 2; i++)
{
doctitle += '_';
}
doctitle += " | ";
doctitle += vv.DocID;
ddlStack.Items.Add(new ListItem(doctitle, vv.vendorID.ToString()));
}
}
You can try either from the below two methods:
1). select new
{
Doctitle = p.DocumentNo+" "+"|"+" "+p.TITLE,
DocId = p.DocId
};
2).
select new
{
Doctitle =Concat(p.DocumentNo,p.TITLE),
DocId = p.DocId
};

How to filter multiple rows in dataview

I need to filter multiple rows in dataview. Here I used rowfilter. But, I want to filter multiple rows. Which command can be used? My code is:
foreach (string s1 in list)
{
if (s1 != string.Empty)
{
dvData.RowFilter = "(code like '" + searchText + "*') AND (code <> '" + s1 + "')";
}
}
The problem is, it takes only one value and it is overwritten during the loop.
If you want to add all codes for code field in RowFilter then you can try this:
StringBuilder sb = new StringBuilder();
foreach(string s in list){
if (s != string.Empty)
sb.Append(string.Format(" AND (code <> '{0}')", s));
}
string rowFilter = string.Format("(code like '{0}*')", searchText) + sb.ToString();
dvData.RowFilter = rowFilter;

Flex's AreaChart bug

What's up with Flex's AreaChart bug, does anybody know how to fix it? It causes ones tooltips to display the wrong value for minFields.
I.e. for:
<mx:AreaSeries yField="TotalVariableCost" minField="TotalFixedCost" displayName="Total Cost">
It will show:
Total Cost
high: TotalVariableCost
low: TotalVariableCost
As opposed to:
Total Cost
high: TotalVariableCost
low: TotalFixedCost
This bug is suppose to be in lines 2058 to 2083 of AreaSeries.as - but that stuff is way beyond my comprehension.
--Stephen
Yep, it's a bug in AreaSeries. Due to the stupid way that flex charts are designed, the only real way to fix it is to set a custom dataTipFunction on the AreaChart.
Here's a copy of the relevant code with the bug fixed:
/**
* Create a data tip function for the given AreaSeries. Uses a copy of
* the formatDataTip code from AreaSeries with the minValue bug fixed.
*
* #param series
* #return a data tip function
*
*/
private function createAreaSeriesTipFunc(series:AreaSeries):Function {
var displayName:String = series.displayName;
var dataTransform:DataTransform = series.dataTransform;
var xField:String = series.xField;
var minField:String = series.minField;
// formatDataTip relies on AreaSeries member data so simulate that
// with a closure to minimize code modifications
return function(hd:HitData):String {
var dt:String = "";
var n:String = displayName;
if (n && n != "")
dt += "<b>"+ n + "</b><BR/>";
var xName:String = dataTransform.getAxis(CartesianTransform.HORIZONTAL_AXIS).displayName;
if (xName == "")
xName = xField;
if (xName != "")
dt += "<i>" + xName + ": </i>";
var item:AreaSeriesItem = AreaSeriesItem(hd.chartItem);
var lowItem:AreaSeriesItem = (minField != "") ?
item :
null;
dt += dataTransform.getAxis(CartesianTransform.HORIZONTAL_AXIS).formatForScreen(item.xValue) + "\n";
var yName:String = dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).displayName;
if (!lowItem)
{
if (yName != "")
dt += "<i>" + yName + ":</i> ";
dt += dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).formatForScreen(item.yValue) + "\n";
}
else
{
if (yName != "")
dt += "<i>" + yName + " (high):</i> ";
else
dt += "<i>high: </i>";
dt += dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).formatForScreen(item.yValue) + "\n";
if (yName != "")
dt += "<i>" + yName + " (low):</i> ";
else
dt += "<i>low:</i> ";
dt += dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).formatForScreen(lowItem.minValue) + "\n";
}
return dt;
};
}
I just changed formatForScreen(lowItem.yValue) to formatForScreen(lowItem.minValue) in one place. You can use it like this:
<mx:AreaChart dataProvider="{chartData}" showDataTips="true" dataTipFunction="{createAreaSeriesTipFunc(areaSeries)}">
<mx:series>
<mx:AreaSeries id="areaSeries" yField="TotalVariableCost" minField="TotalFixedCost" displayName="Total Cost" />
</mx:series>
</mx:AreaChart>

Resources