Trying to data-bind object array using knockout.js into table
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You can access the current iteration of foreach binding with $data variable. also you might want to replace <td data-bind="foreach: Cells">
<!-- ko foreach: Cells -->
<td data-bind="style:{'background-color':$data}></td>
<!-- /ko -->
|
Propel object collection bind column alias to the foreign table object insted of getting it out
Tag : mysql , By : David B
Date : March 29 2020, 07:55 AM
I wish this help you I have two db tables one is Item and the other (Unit) is represent all the measure units available for Item table. In this scenario Item table contains a foreign key of Unit table which acts as one to many relation. , Below approach worked for me : $items = \ItemQuery::create()
->joinWith('Item.Unit')
->withColumn("CONCAT (Unit.Name,'-',Unit.Label)", "MUnit")
->find();
foreach ($items as $i) {
$i->getUnit()->setVirtualColumn('Asdf', $i->getVirtualColumn('MUnit'));
}
dd($items->toJSON());
...
"Items":[
{
"Id":2,
"Code":"M000002",
"Name":"Item 1",
"Price":234,
"UnitId":1,
"MUnit":"Kilograms-Kg",
"Status":true,
"Unit":{
"Id":1,
"Name":"Kilograms",
"Label":"Kg",
"Status":true,
"Asdf":"Kilograms-Kg",// here goes...
}
},
...
|
How can I row bind the unmatch data in the column of first table from the second table
Tag : r , By : Chris Lomax
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further , Try to left join df2 and df1 and replace NA with 0. df3 <- merge(df2, df1, all.x = TRUE)
df3$number[is.na(df3$number)] <- 0
df3
# a number
#1 a 4
#2 b 3
#3 c 2
#4 k 0
#5 z 0
library(dplyr)
df2 %>%
left_join(df1, by = "a") %>%
mutate(number = replace(number, is.na(number), 0))
df3 <- df2
df3$number <- df1$number[match(df2$a, df1$a)]
df3$number[is.na(df3$number)] <- 0
df1 <- data.frame(a = c("a", "b", "c"), number=c(4,3,2))
df2 <- data.frame(a = c("a", "b", "c", "k", "z"))
|
ASP.Net MVC :Jquery Data table with dynamic column bind with JSON
Tag : jquery , By : ponchopilate
Date : March 29 2020, 07:55 AM
Hope that helps Sorry i just could solve it. the moment i add title in column along with data then problem goes out. see my working code var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
TestData t = new TestData();
List<columnsinfo> _col = new List<columnsinfo>();
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(Int32));
dt.Columns.Add("Name", typeof(string));
DataRow dr = dt.NewRow();
dr[0] = 1;
dr[1] = "Ajay";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "Sanu";
dt.Rows.Add(dr);
for (int i = 0; i <= dt.Columns.Count - 1;i++ )
{
_col.Add(new columnsinfo { title = dt.Columns[i].ColumnName, data = dt.Columns[i].ColumnName });
}
string col = (string)serializer.Serialize(_col);
t.columns = col;
var lst = dt.AsEnumerable()
.Select(r => r.Table.Columns.Cast<DataColumn>()
.Select(c => new KeyValuePair<string, object>(c.ColumnName, r[c.Ordinal])
).ToDictionary(z => z.Key, z => z.Value)
).ToList();
string data= serializer.Serialize(lst);
t.data = data;
return View(t);
@model JQDataTable.Controllers.TestData
@{
Layout = "";
ViewBag.Title = "Home Page";
}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://cdn.datatables.net/1.10.15/css/dataTables.bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/responsive/2.1.1/css/responsive.bootstrap.min.css" rel="stylesheet" />
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/dataTables.bootstrap4.min.js "></script>
<div style="display:none;" class="row">
<div class="form-group">
@Html.HiddenFor(m => m.columns, new { @id = "dataObjCol", placeholder = Html.DisplayNameFor(m => m.columns), @class = "form-control" })
@Html.HiddenFor(m => m.data, new { @id = "dataObjData", placeholder = Html.DisplayNameFor(m => m.data), @class = "form-control" })
</div>
</div>
<hr />
<div class="row">
<div>
<table class="table table-striped table-bordered table-hover"
id="TableId"
cellspacing="0"
align="center"
width="30%" border="1"></table>
</div>
</div>
<hr />
<script type="text/javascript">
$(document).ready(function () {
//debugger;
alert($('#dataObjCol').val());
var dataObjCol = JSON.parse($('#dataObjCol').val());
var dataObjData = JSON.parse($('#dataObjData').val());
// Datatable settings.
$('#TableId').DataTable(
{
"data": dataObjData,
"columns": dataObjCol,
"bPaginate": false,
"bFilter": false,
"bInfo": false,
"autoWidth": false,
"bSort": false,
"columnDefs": [
{
"width": "28px",
"targets": "0",
"className": "text-right"
},
{
"width": "2px",
"targets": "1",
"className": "text-right"
}
]
});
});
</script>
public class TestData
{
public string jsondata { get; set; }
public string columns { get; set; }
public string data { get; set; }
}
public class columnsinfo
{
public string title { get; set; }
public string data { get; set; }
}
|
How can I bind dynamic resource key value with column value in data table in wpf
Date : March 29 2020, 07:55 AM
|