You can do that in two ways - either hide the edit command column at runtime based on some condition, or disable the edit buttons inside it on row basis. Feel free to choose the option which is more accurate for your scenario, closing this item.