jQWidgets Forums
jQuery UI Widgets › Forums › Angular › Foreign Key field in datasource for grid column
Tagged: datasource angular grid
This topic contains 1 reply, has 1 voice, and was last updated by scott.erickson@bethesdalc.org 5 years, 11 months ago.
-
Author
-
I have 2 tables categorys and distributions. I’m trying to link the distribution source(distSource) for a grid to category source(catSource) using foreign key CategoryId so I can get the category description(CategoryDescription) into the initial load for that column in the grid it is a combobox type and the dropdown from the categorys works fine, it is just the initial load for the distributions try to use the foreign key categoryId to get the categoryDescription in the categorys. Thank you in advance.
categorys:
public int CategoryId { get; set; }
public string CategoryCode { get; set; }
public string CategoryDescription { get; set; }distributions:
public int DistributionId { get; set; }
public int TransactionId { get; set; }
public string Unit { get; set; }
public int CategoryId { get; set; }`catSource: any =
{
datatype: ‘json’,
datafields: [{ name: ‘categoryId’, type: ‘int’},
{ name: ‘categoryDescription’, type: ‘string’}],
id:”categoryId”,url: environment.server + environment.apiUrl + ‘category’
};source: any =
{
datatype: ‘json’,
datafields: [
//{ name: ‘transactionId’, type: ‘int’ },
{ name: ‘merchant’, type: ‘string’ },
{ name: ‘transactionDate’, type: ‘date’ },
{ name: ‘transactionAmount’, type: ‘float’ },
{ name: ‘merchantCategory’, type: ‘string’ }],
id:”transactionId”,
url: environment.server + environment.apiUrl + ‘fc’
};distSource: any =
{
datatype: ‘json’,
datafields: [
//{ name: ‘transactionId’, type: ‘int’ },
{ name: ‘unit’, type: ‘string’ },
{ name: ‘categoryDescription’, type: ‘string’, value: {source: this.catSource, value: ‘categoryId’, name:’categoryDescription’} },
{ name: ‘distributionAmount’, type: ‘float’ },
{ name: ‘categoryId’, type: ‘int’ }],
id:”transactionId”,
url: environment.server + environment.apiUrl + ‘distribution’};
grid:let distSource = {
datafields: [
//{ name: ‘transactionId’, type: ‘int’ },
{ name: ‘unit’, type: ‘string’ },
{ name: ‘categoryDescription’, type: ‘string’, value:’categoryDescription’ , values: { source:this.catDataAdapter.records, value: ‘categoryId’, name: ‘categoryDescription’}},
{ name: ‘distributionAmount’, type: ‘float’ }
],
id: ‘transactionId’,
localdata: distbyid
}
let nestedGridAdapter = new jqx.dataAdapter(distSource);
if (nestedGridContainer != null) {let settings = {
width: ‘100%’,
height: ‘100%’,
editable:true,
//showfilterrow: true,
//filterable: true,
selectionmode: ‘multiplecellsextended’,
//autowidth: true,
//height: 200,
columnsresize: true,
theme: ‘energyblue’,
source: nestedGridAdapter,
columns: [
//{ text: ‘Unit’, datafield: ‘unit’, width: ‘50%’},
{ text: ‘Unit’, datafield: ‘unit’, width: ‘33%’},
{ text: ‘Category’, datafield: ‘categoryDescription’, columntype:’combobox’,
createeditor: (row: number, value: any, editor: any): void => {
editor.jqxComboBox( { source: this.catDataAdapter, displayMember: ‘categoryDescription’, valueMember: ‘categoryId’});}},
{ text: ‘Amount’, datafield: ‘distributionAmount’, width: ‘34%’}]
};I think I got it figured out. Thank You
-
AuthorPosts
You must be logged in to reply to this topic.