Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question DetailView Use Header Names Not DataFieldId #319

Open
cgountanis opened this issue Jul 31, 2018 · 7 comments
Open

Question DetailView Use Header Names Not DataFieldId #319

cgountanis opened this issue Jul 31, 2018 · 7 comments

Comments

@cgountanis
Copy link

I have to use int id to uniquely identify the columns due to spaces and special char in field names.

data-id-field="id"

Is there a way to use the header names or specify the name when in detail view for the key? Maybe there is another var that is being passed? I tried data-title within the column thinking maybe detail view could pick that up, running out of ideas.

function detailFormatter(index, row) {
	console.log('detailFormatter()');
	var html = [];
	$.each(row, function (key, value) {
		html.push(`<div class="small text-muted"><span class="text-capitalize font-weight-bold">${key}:</span> ${value}</div>`);
	});
	return html.join('');
}

image

@cgountanis
Copy link
Author

Just looking for a tip or some advice here before I have to disable the detail view.

@cgountanis
Copy link
Author

Just saying it would be nice if it used the data-title or the TH name to match. Not many people want to see the raw field name or identifier.

@cgountanis
Copy link
Author

If there is a variable easy to use for human readable header vs fieldname (key) labels let me know. I think we are just moving to a AJAX call in the formatter function itself and getting the data that way. More load time but should work and be easier to customize the output down the road.

@ckarmy
Copy link

ckarmy commented Aug 21, 2019

@cgountanis Can you solve this? I need the same!

@cgountanis
Copy link
Author

cgountanis commented Aug 21, 2019

@cgountanis Can you solve this? I need the same!

I did not solve from any given solution. I did however lower case the JSON property names and simply used BootStrap class "text-capitalize" within a SPAN on the property name to make it look good enough for a dynamic display. Was good enough for us.

@cgountanis
Copy link
Author

Hope this helps a little.

image

$table.on('expand-row.bs.table', function (e, index, row, $detail) {
	$detail.html(loadingMessage);
	var documentId = row[1];
	var url = '/api/data/' + documentId;
	$.get(url, function (data) {
		if (data !== null) {
			var html = [];
			html.push('<div class="row p-0 m-0">');
			$.each(data, function (k, v) {
				html.push('<div class="col-xl-3 small text-muted"><span class="text-capitalize font-weight-bold">' + k + ':</span> ' + v + '</div>');
			});
			html.push('</div>');
			$detail.html(html.join(''));
		}
	});
});

@ckarmy
Copy link

ckarmy commented Aug 21, 2019

Great! Thanks a lot!!! @cgountanis Thats was looking for! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants